Attribute customization scripts / Calculated Values Scripts
My code is not mapping it on work item Presentation
dojo.provide("com.rc.TaskDuration");
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;
var fromISOString = dojo.date.stamp.fromISOString;
dojo.declare("com.rc.TaskDuration", 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, " + hours + " hr, " + minutes + " min";
}
return "";
}
});
})();
As i am mapping it with a variable of type Long.
Please give me any solution.
Accepted answer
Comments
I am not even getting value when just i try to post creation Date against my attribute with Type Timestamp/ Date.
I mean to say that no value is pointed at work item presentation.
What do you expect to see in the presentation if you return no data or the wrong type?
What ever just wanted to see if something is come into presentation even it can be static value.
You have to return a value that is compatible with the value of the attribute, otherwise all you will see is an error in the log. Consider going through Process Enactment Workshop for the Rational solution for Collaborative Lifecycle Management the RTC only version.
1 vote
One other answer
Comments
But still i am not getting value mapped on Work item. It is showing nothing in value.
Do you added the creation date as an dependent attribute?
1 vote
Yeh, i already set Creation date as dependency,
and it is not even showing static string output.