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

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

 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;


}); 
})(); 


1

1 vote


Accepted answer

Permanent link
 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

2 votes


One other answer

Permanent link
 Hi Jim,

this works :)

Thank you very much..

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
× 12,029
× 7,507
× 57
× 35

Question asked: May 16 '13, 9:03 a.m.

Question was seen: 6,744 times

Last updated: May 17 '13, 4:00 a.m.

Confirmation Cancel Confirm