Can anyone help me with a Calculated Value attribute customization script for Story Points?
We are attempting to write an attribute customization calculated value script to clear the story points of a Story when the Story moves to the Invalid state. I am able to do something similar with the time spent field so I thought I could do it with Story Points. I have written the script included below and have set it as the calculated value script for the Story Points attribute of the Story work item along wiht a Dependency on the Status field. When I use it, I don't get any error but I also don't see the Story Points field change. The id of the '0 pts' story point value is "0" and that is what I am returning.
/***********
*
***********/
dojo.provide("com.gdms.rtc.ValueProvider.ClearInvalidStoryPoints");
(function() {
var scriptName= "ClearInvalidStoryPoints";
dojo.declare("com.gdms.rtc.ValueProvider.ClearInvalidStoryPoints", null, {
getValue: function(attribute, workItem, configuration) {
var stryPts = workItem.getValue("com.ibm.team.apt.attribute.complexity");
var state = workItem.getValue("com.ibm.team.workitem.attribute.state");
var rtype = workItem.getValue("com.ibm.team.workitem.attribute.workitemtype");
/ Check to see if the type/state pairing is one we care about /
/ Story ==> Invalid (.s2) */
if ((rtype.lastIndexOf("story") > -1) && (state.lastIndexOf("s2") > -1)) {
stryPts = "0";
}
return stryPts;
}
});
})();
Thank you,
Accepted answer
As far as I am aware, story points is an enumeration. In that case you would set a specific literal that represents the null. It might be customized so you should check what it is.
It is always a good idea to check the type of an attribute before trying to customize it. It is also a good idea to look into what the application thinks are the values e.g. with the "Spy" calculated value in the enactment workshop, by logging or using debugging. All these approaches save time.
Comments
These attribute definitions do not exist:
var state = workItem.getValue("com.ibm.team.workitem.attribute.state"); var rtype = workItem.getValue("com.ibm.team.workitem.attribute.workitemtype");
See https://jazz.net/wiki/bin/view/Main/AttributeCustomization for the API. You can find the work item attribute ID's in the web admin UI.
Story points is a custom attribute with ID the ID you have there.
State is "internalState" or WorkItemAttributes.STATE.
The type attribute ID is "workItemType" or WorkItemAttributes.TYPE I would suggest to follow the workshop or at least look at https://jazz.net/library/article/1360
Ralph,
Ralph,