Iteration default value with script based
![](http://jazz.net/_images/myphoto/991e77e31bba852766d2dab30e129b81.jpg)
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
![](http://jazz.net/_images/myphoto/991e77e31bba852766d2dab30e129b81.jpg)
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
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
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
![](http://jazz.net/_images/myphoto/991e77e31bba852766d2dab30e129b81.jpg)
Hello,
![](http://jazz.net/_images/myphoto/0227396f4efb17d0baa0c12dd70df878.jpg)
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.