It's all about the answers!

Ask a question

JODO script to set current time for a timestamp attribute


seshu kumar pamidi (21311) | asked Oct 18 '15, 5:49 a.m.
HI All,

I want to set the current time for a attribute based on the value change of another attribute,

Can some one please help me with an example script how to do this.

Change of the estimate attribute, I want to set the due date attribute to current system date lets say as an example.

Please help me on this.

Accepted answer


permanent link
Donald Nong (14.5k614) | answered Oct 18 '15, 6:40 p.m.
By "JODO", do you mean Dojo? If so, you can find plenty of examples on this forum.
https://jazz.net/forum/questions/65781/setting-default-values-for-timestamp-custom-attribute
https://jazz.net/forum/questions/113192/work-item-attribute-customization-how-to-set-current-date-in-timestamp-attribute
https://jazz.net/forum/questions/77931/attribute-configuration-calculated-timestamp-being-set-unexpectantly
seshu kumar pamidi selected this answer as the correct answer

Comments
seshu kumar pamidi commented Oct 19 '15, 5:18 a.m. | edited Oct 23 '15, 6:07 a.m.



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

(function() {
dojo.declare("example.calculated.TimeStampChange", null, {
getValue: function(attribute, workitem, configuration) {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var currentDate= new Date();
var datum = currentDate.getDate();
var mjesec = currentDate.getMonth() + 1;
var godina = currentDate.getFullYear();
var currentDateString= dojo.date.stamp.toISOString(currentDate, {milliseconds:true, zulu:true});
var systemDate = dojo.date.stamp.toISOString(new Date(godina, mjesec, datum), {milliseconds:true, zulu:true});
var result = "0";
var defectStatus = workitem.getLabel(WorkItemAttributes.STATE);

if(defectStatus == "Resolve"){
result = currentDateString
}

return result;
}



after running this script, it the defect status is of state resolve, my custom timestamp attribute need to be set wil current time, which is not happening

Also the result attribute is giving some old date, is it possible to set the date as NONEĀ  instead of some old date


seshu kumar pamidi commented Oct 19 '15, 5:23 a.m.



after running this script, if the defect is of state resolve, my custom timestamp attribute need to set with current time, which is not happening

Also is the state is of some other instead of Resolve , the timestamp attribute is set with some old date, is it possible to set the date as NONEĀ  instead of some old date


Your answer


Register or 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.