How to get calculated value script to fire when status is changed?
![](http://jazz.net/_images/myphoto/936a56f64cd0bc593b248212cd08bd35.jpg)
(function() {
dojo.declare("com.example.storyPointsBlankOnInvalid", null, {
getValue: function(attribute, workItem, configuration) {
alert("Inside HERE");
return workItem.getValue(attribute);
}
});
})();
2 answers
![](http://jazz.net/_images/myphoto/936a56f64cd0bc593b248212cd08bd35.jpg)
Comments
![](http://jazz.net/_images/myphoto/936a56f64cd0bc593b248212cd08bd35.jpg)
If you can think of a better way, please let me know.
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
I know that what you ask for has been done before. In this case it might not be necessary to detect a state change. It might be enough to be able to determine the current state. I would suggest to try Davyds suggestion. I can not tell if it would work at the moment. The point is, from my perspective, when the calculated value is actually executed. E.g. the user selects the action to change the state and presses save. Is the calculated value calculated after the save and now the user would have to save again?
![](http://jazz.net/_images/myphoto/936a56f64cd0bc593b248212cd08bd35.jpg)
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.example.storyPointsBlankOnInvalid", null, {
getValue: function(attribute, workItem, configuration) {
if (workItem.getValue(WorkItemAttributes.STATE) === 'the.id.value.of.your.state') {
return ''; /* or whatever a blank value is for this attribute */
} else {
return workItem.getValue(attribute);
}
}
});
})();
Comments
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
I think my answer is on point. The thing is that there is nothing in a calculated value that would (easily) allow you to detect a state change. You can get the current state by reading the state attribute. There are no real means, I would be aware of, to know the previous state.
![](http://jazz.net/_images/myphoto/155c3d4adb1050c9fad99139dab14b77.jpg)
![](http://jazz.net/_images/myphoto/155c3d4adb1050c9fad99139dab14b77.jpg)
That was why I replied - your response is all true, but she's not interested in picking up the actual change, only the current value