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

Customizing calculated value but get NaN as result

Hi, I'm trying to get a calculated value on a custom attribute, this attribute is an integer type, and is also integer kind on presentation. I want it to count each time it reaches to an specific state. I'm using the following script:

dojo.provide("counterString");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("counterString", null, {
    getValue: function(attributeId, workItem, configuration) {
    var counter = parseInt(workItem.getValue("counterString"));
    console.log("Counter: " + counter + "\n\n");
        var stat = workItem.getValue(WorkItemAttributes.STATE);
        console.log(counter);
        console.log(stat);
        if(stat === "s5")
            {  
                console.log("Actual value:" + counter);
                counter = counter+1;
                console.log("New Value:" + counter);
            }
                return parseInt(counter);
    }
});
})();

The state condition works fine, but not for the counter, when I check my log it says "Counter: NaN".
What should I change on my script?

0 votes



One answer

Permanent link
I solve this on my own. I hope this helps anyone who had a similar problem.

dojo.provide("counterString");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
var counter = 0;
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("counterString", null, {
    getValue: function(attributeId, workItem, configuration) {
    console.log("Counter: " + counter + "\n\n");
        var stat = workItem.getValue(WorkItemAttributes.STATE);
        console.log(counter);
        console.log(stat);
        if(stat === "s5")
            {  
                console.log("Actual value:" + counter);
                counter= counter+1;
                console.log("New value" + counter);
            }
                return parseInt(counter);
    }
});
})();

0 votes

Comments
I got an issue, everytime I refresh the webpage, the counter increases on 3, and when I check the log it shows like the WI was saved 3 times. why is that if I'm only refreshing the webpage? Any tip please???

Thanks,

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
× 10,938

Question asked: Aug 27 '18, 5:21 a.m.

Question was seen: 1,722 times

Last updated: Aug 27 '18, 7:17 p.m.

Confirmation Cancel Confirm