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
Accepted answer
See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript
you have to convert it back to an iso string using dojo.date.stamp.toISOString before you return it.
-
Timestamp as an ISO-8601 standard string. Use
dojo.date.stamp
to convert a JavascriptDate
object to and from an ISO-8601 string. When converting aDate
object to a string set themilliseconds
and thezulu
options to true.-
To convert the value of a timestamp attribute with the id
attributeId
to aDate
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});
-
To convert the value of a timestamp attribute with the id
you have to convert it back to an iso string using dojo.date.stamp.toISOString before you return it.