Is there way to set Planned for using calculated value script?
![]()
I know the syntax for getting the current state but I need to know what is the syntax to set the Planned for value to a particular iteration. Do we use the iteration name, identifier or id?
|
Accepted answer
![]()
Generally you can get the UUID value to set the value like the below.
var type = workItem.getValue(WorkItemAttributes.TYPE);
if ((type === "defect")) {
return "_itagAaMNEeKaNcD4tX8gjw";
} else {
return "_itagBKMNEeKaNcD4tX8gjw";
}
Reference: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_based_calculated_values
Now you may have a question how to know the UUID value each Planned for ID?
One of ways is creating another script to populate the UUID value into an attribute.
dojo.provide("org.example.Planned_For_ID");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes=
com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.Planned_For_ID", null, {
getValue: function(attributeId, workItem, configuration) {
return workItem.getValue(WorkItemAttributes.PLANNED_FOR);
}
});
})();
Reference: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_built_in_attributes_of
Ralph Schoon selected this answer as the correct 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")
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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); ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Your question has already been answered by @tnakajo pretty much.
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.
showing 5 of 6
show 1 more comments
|
2 other answers
![]()
Ralph Schoon (61.8k●3●36●43)
| answered Jul 10 '15, 2:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Yes, if you don't want to hard code the UUID and do something more fancy, see https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/
The problem I see is that automating planning is likely to produce even more problematic results than if humans do it. |
![]()
OK this is my code, Can someone help me find how to update the Planned_for section (commented)
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 ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.
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
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Configuring_additional_script_pa for how to add parametrization for scripts.
|