Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.


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.

0 votes


Accepted answer

Permanent link

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

0 votes

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,


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

Jamie. 

 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 log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Feb 16 '18, 4:25 p.m.

Question was seen: 1,927 times

Last updated: Feb 19 '18, 5:49 p.m.

Confirmation Cancel Confirm