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

Defect Count

 Hi All,


Basically, when ever the defect fails during testing it will be reopened, and the counter should increment by 1.
I used Dojo Script to calculate the defect reopen count. (Custom Attribute Type is Integer)
In Reopen State the count is incrementing but the problem is, If I do any changes in Reopen State and Save it, again the count is incrementing.
Don't have any clue why the counter is incrementing when doing changes in Reopen State.

Script... 

dojo.provide("defectopencounter"); 
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); 
(function() { 
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; 
dojo.declare("defectopencounter", null, { 
    getValue: function(attributeId, workItem, configuration) { 
    var defectcount = parseInt(workItem.getValue("com.ibm.team.atribute.defect")); 
        var stat = workItem.getValue(WorkItemAttributes.STATE); 
        
        if(stat === "com.ibm.team.workitem.defectWorkflow.state.s6") 
            {    
                 
                defectcount = defectcount+1; 
                 
            } 
                return parseInt(defectcount); 
    } 
}); 
})(); 

0 votes



2 answers

Permanent link

Hi Kiran

I guess com.ibm.team.workitem.defectWorkflow.state.s6 is the reopened state. In your script, the logic is
when it is at reopened state, each save will add 1 to defect count.
So the result is expected.
What you want is to count only when there is state changed to reopen hence you would need to have another attribute storing previous state and by comparing that state with the current state, when there is a state change and state is com.ibm.team.workitem.defectWorkflow.state.s6 then you increase 1 to defect count.

There is some explanation in the below two posts:
https://jazz.net/forum/questions/224213/reopen-action-counter-using-attribute-customization-in-dojo-js
https://jazz.net/forum/questions/226599/can-i-generate-other-attributes-that-pull-current-date-when-state-changed

0 votes


Permanent link

In addition to Dons comment please note that attribute calculation scripts can run multiple times and not, which is likely your assumption, only once. See https://jazz.net/wiki/bin/view/Main/AttributeCustomization for a description.
You also want to carefully read the section about state id's and special cases in the same documentation.

Maybe Dons links help.
 

0 votes

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
× 57
× 35
× 32

Question asked: Feb 13 '18, 5:14 a.m.

Question was seen: 2,221 times

Last updated: Feb 14 '18, 1:58 a.m.

Confirmation Cancel Confirm