It's all about the answers!

Ask a question

Iteration default value with script based


David MICHEL (1472548) | asked Sep 11 '17, 6:07 a.m.

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

One answer



permanent link
Donald Nong (14.5k614) | answered Sep 14 '17, 6:36 a.m.

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.


Comments
Ralph Schoon commented Sep 14 '17, 7:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


David MICHEL commented Sep 15 '17, 9:20 a.m.

 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 ?


Donald Nong commented Sep 17 '17, 8:57 p.m.

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 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.