Is there way to set Planned for using calculated value script?
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
Comments
showing 5 of 6
show 1 more comments
2 other answers
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.
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")
}
});
})();
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"); }
}
});
})();