RTC - Date Difference Script
Hi The following script is not working. Request your help. I have created a custom attribute of Integer type and added Due Date as dependency but the result is shown as 0.
dojo.provide("com.example.DateDifference");
(function() {
getValue: function(attributeId, workItem, configuration) {
var dueDate = dojo.date.stamp.fromISOString(workItem.getValue(WorkItemAttributes.DUE_DATE));
Regards Niranjan V
|
Accepted answer
Ralph Schoon (63.3k●3●36●46)
| answered Jul 13 '15, 5:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Jul 13 '15, 5:07 a.m.
The script has to return the date like this:
/******************************************************************************* * Licensed Materials - Property of IBM * (c) Copyright IBM Corporation 2011. All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * Use, duplication or disclosure restricted by GSA ADP Schedule * Contract with IBM Corp. *******************************************************************************/ dojo.provide("com.team.example.CurrentDate"); dojo.require("dojo.date"); // We need the date class from Dojo to compare two dates dojo.require("dojo.date.stamp"); // We need the stamp class to work with ISO date strings (function() { dojo.declare("com.team.example.CurrentDate", null, { getDefaultValue: function(attribute, workItem, configuration) { var now=new Date(); var date= dojo.date.stamp.toISOString(now, {milliseconds:true, zulu:true}); return date; } }); })();As explained in https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript (carefully read it) the date has to be returned as ISOString so you have to convert it back like this: var date= dojo.date.stamp.toISOString(now, {milliseconds:true, zulu:true}); V Niranjan selected this answer as the correct answer
|
One other answer
Ralph Schoon (63.3k●3●36●46)
| answered Jul 12 '15, 6:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
It is not working, because you don't convert the date back to something RTC can understand.You use fromISOString to get the date format and you have to use toISOString for the format to be converted to return it. See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript
Comments
V Niranjan
commented Jul 13 '15, 4:41 a.m.
Hi Ralph
|
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.