It's all about the answers!

Ask a question

dojo script do not work in date field


Pankaj Sharma (401169) | asked Aug 11 '16, 10:12 p.m.
edited Aug 11 '16, 10:14 p.m.
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

Accepted answer


permanent link
Ralph Schoon (63.1k33645) | answered Aug 12 '16, 2:53 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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

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.