Why is this script not returning any Calculated Value
I have
(1). Created a new Custom Field (2). I have associated the below script with the Custom Attribute, I created above via the "Calculated Field" (3). And yet when I make any modification to the WI, the custom field is not being populated as expected dojo.provide("example.calculated.TotalTimeSpent"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); dojo.require("dojo.date.stamp"); (function() { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; var fromISOString = dojo.date.stamp.fromISOString; dojo.declare("example.calculated.TotalTimeSpent", null, { getValue: function(attribute, workItem, configuration) { var creationDate = workItem.getValue(WorkItemAttributes.CREATION_DATE); if (creationDate) { var ageInSeconds = (Date.now() - creationDate.getTime()) / 1000; var days = parseInt(ageInSeconds / 86400); var hours = parseInt((ageInSeconds-days * 86400) / 3600); var minutes = parseInt((ageInSeconds-days * 86400 - hours * 3600) / 60); return days + " d, " + hours + " hr, " + minutes + " min"; } return "X"; } }); })(); |
5 answers
Ralph Schoon (63.3k●3●36●46)
| answered May 20 '16, 2:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Many possible issues
|
Hi Ralph,
I have checked the syntax in the script, I have removed the "If Creation Date" all together, I have modified date and Creation date as the dependent attributes and yet the Custom Attribute "TotalTimeSpent" is not getting populated. I put the fromISOString in front of the call because the exact same script works in another RTC Instance dojo.provide("example.calculated.TotalTimeSpent"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); dojo.require("dojo.date.stamp"); (function() { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; var fromISOString = dojo.date.stamp.fromISOString; dojo.declare("example.calculated.TotalTimeSpent", null, { getValue: function(attribute, workItem, configuration) { var creationDate = fromISOString(workItem.getValue(WorkItemAttributes.CREATION_DATE)); var ageInSeconds = (Date.now() - creationDate.getTime()) / 1000; var days = parseInt(ageInSeconds / 86400); var hours = parseInt((ageInSeconds-days * 86400) / 3600); var minutes = parseInt((ageInSeconds-days * 86400 - hours * 3600) / 60); return days + " d, " + hours + " hr, " + minutes + " min"; } }); })(); Comments It might be a good strategy to start with a simple script that just returns a fixed value, if in doubt. Maybe use some techniques for debugging as described in
Sivarajah Rajeswaran
commented May 23 '16, 8:06 p.m.
I tried the simplest of scripts and got the following error in the .log file
Donald Nong
commented May 23 '16, 8:15 p.m.
It could be due to syntax errors or other configuration problems. I suggest you remove the Caculated Value completely and start over again.
Sivarajah Rajeswaran
commented May 26 '16, 11:46 p.m.
Hi I did that and have the RTC provided script with a constant being returned and still not not return any result
|
Comments
Sivarajah Rajeswaran
commented May 26 '16, 11:57 p.m.
Here is the message from the .log file but I am not sure what this means
|
I tried the simplest of scripts and got the following error in the .log file
Comments
Ian Wark
commented May 30 '16, 2:43 a.m.
Have you checked that the project area has enabled scripting?
Configuring a script-based customization by attaching a Javascript implementation
|
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.