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

Defect age script

Hi all,

I have a dojo script which helps to display the Defect age,

Till today afternoon its worked fine, but suddenly it is displaying defect age is 3d old for a defects created after 1PM.

Request your help and suggestion..

Thank You...!

dojo.provide("example.calculated.defectAgeValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date.stamp");

(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var fromISOString = dojo.date.stamp.fromISOString;
  dojo.declare("example.calculated.defectAgeValueProvider", null, {

    getValue: function(attribute, workItem, configuration) {
      var creationDate = fromISOString(workItem.getValue(WorkItemAttributes.CREATION_DATE));
      if (creationDate) {
        var ageInSeconds = (Date.now() - creationDate.getTime()) / 1000;

        var days         = parseInt(ageInSeconds / 86400);
        var hours        = parseInt((ageInSeconds-days * 86400) / 3600);
        var minutes      = parseInt((ageInSeconds-days * 86400 - hours * 3600) / 60);
               
        return days + " d ";
      }
      return " ";
    }
  });
})();

0 votes



One answer

Permanent link
This has worked for me in a different context
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes
dojo.require("dojo.date"); // We need the date class from Dojo to compare two dates
dojo.require("dojo.date.stamp"); // We need the stamp class to work with ISO date strings

.
.
.

        var beginDate = dojo.date.stamp.fromISOString(workItem.getValue("WorkItemAttributes.CREATION_DATE")); 
        // Compare the two dates returns negative value due to order
        var compare = (dojo.date.difference(Date.now(), beginDate, "day"));
        return compare + " d ";

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
× 152

Question asked: Jan 25 '16, 7:49 a.m.

Question was seen: 2,643 times

Last updated: Jan 25 '16, 8:24 a.m.

Confirmation Cancel Confirm