calculation of Task Age based on Due Date
We have a business requirement that task age to be calculated based on the due date assigned for first time and ignore calculation if its updated in later time.
Task age (in days) = Current date - Due date(assigned first time only)
The following script returns Task age based on due date but when ever due date is changed task age is also getting updated which should not be case, is there a way the scripts needs to be taken into account only the first time assigned due date and ignore subsequent modifications in due date.
dojo.provide("taskage");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("taskage", null, {
getValue: function(attribute, workItem, configuration) {
var t1= dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.DUE_DATE));
var t2= new Date();
if (t1 === null) return "";
var diff = dojo.date.difference(t2, t1, "day");
return diff;
}
});
})();
RTC version used is 6.0.2
Thanks in Advance.
|
One answer
The value WorkItemAttributes.DUE_DATE is updated when due date is updated. So it will ALWAYS return the current value stored.
if you want the ORIGINAL due date, then store it in a different attribute ( say ORIG_DUE_DATE )and set its value when due date is initially set. Then you can use it as workItem.getValue(WorkItemAttributes.ORIG_DUE_DATE)
|
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.