Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Iteration default value with script based

Hello,
   In Custom attributes (RTC), I wish to add a Scripts based Default value to set an iteration who depends on the workitem type:
I have tried this code but It doesn't work:
dojo.provide("com.example.DefaultValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
    dojo.declare("com.example.DefaultValueProvider", null, {

        getDefaultValue: function(attribute, workItem, configuration) {
              var categorie = workItem.getValue(WorkItemAttributes.FILED_AGAINST);
             var type = workItem.getValue(WorkItemAttributes.TYPE);
              if (type == "WI1" ) {
                  return "categorie 1";
            }
             if (type == "WI2" ) {
                   return "categorie 2";
               }

        }
    });
})();

I think that I mustn't return a string for the category attribute but I don't know what I must return.

Could you help me ?

Best regards

David

0 votes



One answer

Permanent link

For Iteration type, you need to return the UUID of an iteration, something like "_X-Njx2FdEeeM_dwgFcOBoQ". I don't know any easy ways to get the UUID. The reportable REST API is one such way.
https://jazz.net/wiki/bin/view/Main/ReportsRESTAPI#iteration_type_com_ibm_team_proc

Note that your code will not work anyway, as the default value usually only makes sense when the work item is being created, for the first time, where most of the attributes are just empty.

The way you write the code is more of the Calculated Value provider.

0 votes

Comments

He is also confusing the category (Filed Against) and the iteration (Planned for).
To get such values my best tip is to peek into them, see attribute value spy in https://jazz.net/library/article/1093

 Hello,

    Thank for your returns.
I wanted to use category (Filed Against) and not the iteration. I can get the UUID for each category in writting the value of "workItem.getValue(WorkItemAttributes.FILED_AGAINST); " in another attribute.

Otherwise I understand that I can't set a default value on category based on a javascript script without developping  a new java default provider.
Is it correct ?

I believe you can set a default value. But if the default value is based on other conditions, such as another attribute with a user-defined value, then it may not work well. It's about the timing of the execution of the script, rather than the technologies being utilized.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,954

Question asked: Sep 11 '17, 6:07 a.m.

Question was seen: 2,257 times

Last updated: Sep 17 '17, 8:57 p.m.

Confirmation Cancel Confirm