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

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.

0 votes



One answer

Permanent link

 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)

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

Question asked: May 07 '18, 7:25 a.m.

Question was seen: 2,788 times

Last updated: Apr 16 '19, 10:00 a.m.

Confirmation Cancel Confirm