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

dojo script do not work in date field

I am using RTC 6.0.2
i am writing a script to update one date filed from other date fields, and its not working, But when i use the same script to populate it in a string attribute it works
below is my code

var BetaReleaseDate = '';

var ReplannedReleaseDate = '';

var CurrentBetaReleaseDate = '';

BetaReleaseDate = dojo.date.stamp.fromISOString(workItem.getValue('com.ibm.team.workitem.attribute.BetaReleaseDate')); ReplannedReleaseDate = dojo.date.stamp.fromISOString(workItem.getValue('com.ibm.team.workitem.attribute.RePlannedSwBetaReleaseDate')); //CurrentBetaReleaseDate = dojo.date.stamp.fromISOString(workItem.getValue('com.ibm.team.workitem.attribute.CurrentBetaReleaseDate'));
if (BetaReleaseDate != null && ReplannedReleaseDate != null ) { return ReplannedReleaseDate; } else if(BetaReleaseDate != null){
return BetaReleaseDate; }
else{ return CurrentBetaReleaseDate; }                }

please help

0 votes


Accepted answer

Permanent link
See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript

  • Timestamp as an ISO-8601 standard string. Use
    dojo.date.stamp to convert a Javascript
    Date object to and from an ISO-8601 string. When converting a
    Date object to a string set the
    milliseconds and the
    zulu options to true.
    • To convert the value of a timestamp attribute with the id attributeId to a Date object use:
      var date= dojo.date.stamp.fromISOString(workItem.getValue(attributeId));
      					
    • To convert a Date object to an ISO-8601 string use:
      var string= dojo.date.stamp.toISOString(date, {milliseconds:true, zulu:true});
      					




you have to convert it back to an iso string using dojo.date.stamp.toISOString before you return it.
Pankaj Sharma selected this answer as the correct answer

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

Question asked: Aug 11 '16, 10:12 p.m.

Question was seen: 2,044 times

Last updated: Aug 12 '16, 2:53 a.m.

Confirmation Cancel Confirm