Use Calculated value Javascript to set the value of multiple attributes from a single call
When creating a script for a calculated value, I have no problem returning the calculation to the calling attribute using the return command, but can't seem to figure out how to store a calculated value in a different attribute without calling the script in the other attribute?
I'll admit I'm not java savvy, but am just looking to explicitly set the value of a different attribute from a script in another attribute.
As an example, I have an attribute Last_State which stores the compares the current value of the Last_State and the current value of the workflow state. If they're different, I want to update the timestamp of a different attribute, and at the end of the script, update the Last_State to the workflow state using the return.
dojo.provide("Last_State_Updater");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date.stamp");
(function() {
dojo.declare("Last_State_Updater", null, {
getValue: function(attribute, workItem, configuration) {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var workFlowState = workItem.getLabel(WorkItemAttributes.STATE);
if (workFlowState != workItem.getValue("Last_State")){
switch(workFlowState){
case("Requirements development"):
//Store the current last modified timestamp in the Requirements development Time Attribute
break;
case("Design phase"):
//Store the current last modified timestamp in the Design phase Time Attribute
break;
case("Implementation phase"):
//Store the current last modified timestamp in the Implementation phase Time Attribute
break;
case("Unit test phase"):
//Store the current last modified timestamp in the Unit test phase Time Attribute
break;
default:
break;
}
}
return workFlowState.toString();
}
});
})();
Thanks in advance for the help!
One answer
First, this is JavaScript and not Java. Not that it matters for the result.
Calculated values can only (and must) return a value. You can not 'set' anything in such a script.
As far as I know the states of a work item can not be set.