Is there way to set Planned for using calculated value script?
Accepted answer
Comments
You mean declare planner_for var and then set it? Does this format work?
........ var Plannedfor = workItem.getValue(WorkItemAttributes.PLANNED_FOR);
......... if (workItem.getValue(WorkItemAttributes.STATE) === "s1")
{ Plannedfor ="this_time_line"; }
else
return Plannedfor;
}
});
})();
No, it won't in JavaScript you have to return the UUID in for IItem type attribute types.
Is't it as simple as . My need is how to set the value for Planned for field in the script
workItem.setValue(WorkItemAttributes.PLANNED_FOR, this_time_line);
Your question has already been answered by @tnakajo pretty much.
You have to find the UUID of the Iteration - by looking at the URL in the browser and then return it. e.g.
return "_itagAaMNEeKaNcD4tX8gjw";
Read https://jazz.net/wiki/bin/view/Main/AttributeCustomization and
If you want more API and search queries by name you would have to use Java.
Thanks! I really struggled to get the UUID into var without needing another attribute, but I got using another attribute as suggested and its working now
Hi, Uma, I'm happy to see you worked out. I also appreciate Ralph's help.
2 other answers
The problem I see is that automating planning is likely to produce even more problematic results than if humans do it.
dojo.provide("ibm.custom.script.IterationByStatus");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("ibm.custom.script.IterationByStatus", null, {
getValue: function(attribute, workItem, configuration) {
var state= workItem.getValue(WorkItemAttributes.STATE);
console.log(typeof(state))
if(state === "com.ibm.team.workitem.taskWorkflow.state.s4")
{ workItem.setValue(WorkItemAttributes.PLANNED_FOR, "Recycle Bin"); }
}
});
})();
Comments
I find it quite surprising when you ask questions and then don't consider to apprehend the answers. Your question has been answered already. You can not use the displayname of the iteration, you HAVE to use the UUID of the iteration.
A UUID looks similar to the first answer: "_itagAaMNEeKaNcD4tX8gjw" and you can find the UUID in links or by printing it from the attribute uisng a script. See
Is there a way to set the UUID derived from the script to a var and use it in my script? I am not sure how acquire the UUID value by printing attribute using a script
See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Configuring_additional_script_pa for how to add parametrization for scripts.