It's all about the answers!

Ask a question

Can anyone help me with a Calculated Value attribute customization script for Story Points?


Jamie Berry (14013079) | asked Feb 16 '18, 4:25 p.m.

 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.


Does anyone know what I am doing wrong?

/***********
*
***********
/
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,
Jamie.

Accepted answer


permanent link
Ralph Schoon (60.9k33643) | answered Feb 17 '18, 9:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Jamie Berry selected this answer as the correct answer

Comments
Ralph Schoon commented Feb 19 '18, 7:20 a.m. | edited Feb 19 '18, 7:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


Jamie Berry commented Feb 19 '18, 9:39 a.m.

Ralph,


  Thank you for the additional information.  I will read through the references and work on debugging my code.  I appreciate your help.

Jamie. 


Jamie Berry commented Feb 19 '18, 5:49 p.m.

 Ralph,


  Thank you again for the help.  I was able to clean up my script and get things to work.

Jamie.

Your answer


Register or to post your answer.