It's all about the answers!

Ask a question

work item attribute customization: how to set current date in timestamp attribute


1
1
Milan Krivic (98010172139) | asked May 16 '13, 9:03 a.m.
 Hi, 

I would like to set current date as default value in DUE DATE attribute. I 've done this script, and it works for simple text string attribute, but not for DUE DATE:



dojo.provide("com.apisit.providers.TrenDatum");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");


(function() { 

dojo.declare("com.apisit.providers.TrenDatum", null, {
getDefaultValue: function(attribute, workItem, configuration) { 

var currentDate= new Date();
var datum = currentDate.getDate();
var mjesec = currentDate.getMonth() + 1;
var godina = currentDate.getFullYear();
var cijeli = datum+"."+mjesec+"."+godina+".";
return cijeli;


}); 
})(); 


Accepted answer


permanent link
Jim Ruehlin (79114) | answered May 16 '13, 5:04 p.m.
JAZZ DEVELOPER
 Hi Milan,

You need to use dojo.date.stamp to convert the JavaScript date to an RTC timestamp (which is an ISO 8601 string). You also need to set the milliseconds and zulu options to be true. Try something like this:
var cijeli = dojo.date.stamp.toISOString(new Date(godina, mjesec, datum), {milliseconds:true, zulu:true});
Milan Krivic selected this answer as the correct answer

One other answer



permanent link
Milan Krivic (98010172139) | answered May 17 '13, 4:00 a.m.
 Hi Jim,

this works :)

Thank you very much..

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.