defect reopen count using dojo scripting calculated value
Hi, the following is the DOJO script to calculate the defect reopen counter, basically when ever the defect fails during testing it will be reopened, and the counter should increment by 1. Dont have a clue why the counter is incrementing twice when the defect is reopened, any idea appreciated. so this script gets executed whenever the status is changed.
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("defectopencounter"));
var stat = workItem.getValue(WorkItemAttributes.STATE);
var act=configuration.getWorkflowAction();
if(stat === "1")
{
console.log("yes status is Open");
console.log("the current count value:" + defectcount);
defectcount = defectcount+1;
console.log("the current count value after addition:" + defectcount);
}
return parseInt(defectcount);
}
});
})();
Accepted answer
Read the documentation: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Calculated_values
Script-based calculated values
Note: You can find general information about script-based attribute customization in the Using scripts for attribute customization section.If you configure a Script-based calculated value, the script will be executed in three cases:
- When a work item is created, the script is executed
- When a work item is saved, the script is executed to recalculate the value.
- When an attribute which the current attribute depends on is changed, the value of the current attribute is recalculated. Depending on the presentations of the two attributes this may not work in all cases.
Comments
thanks Ralph, your input guided me to the right point. All i did is removed the Status from dependency on the defectopencounter attribute. Now web and eclipse client are working as expected. thanks a lot.
Also, var act=configuration.getWorkflowAction(); this statement is not required and can be removed.
Comments
demo demo
Jan 26 '17, 9:27 a.m.also noticed its working correctly in web interface, however on eclipse client the value is incremented by 2.