My delay script is not working
![]()
Here's my script:
I have a custom attribute Baseline End Date (ID: project.baselineduedate | Type: Timestamp) and I want to calculate the difference between the current date and the Baseline End Date and show it.
I created the custom attribute "Project Delay" of type Decimal, calculated value: Project Delay, dependencies Baseline End Date and Read-Only presentation. I still don't find my error.
Any help is hugely appreciated.
Georges
|
Accepted answer
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Feb 23 '15, 3:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can not simply use + and - to operate on dates. You can not simply return a data. See https://jazz.net/wiki/bin/view/Main/AttributeCustomization#API_for_Javascript and look at the Timestamp section. Search the internet for how to operate on dates with JavaScript
Here is example code for calculating: dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes 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 . . . . . var message= "Date must be at least 30 days from now"; // Work Item new: not initialized - provides todays date. Once created provides the creation date var beginDate = dojo.date.stamp.fromISOString(workItem.getValue("com.ibm.team.workitem.attribute.creationdate")); // Get the current attribute's value and make a Date object from it console.log("I got: ["+workItem.getValue(attributeId)+"]"); var endDate= dojo.date.stamp.fromISOString(workItem.getValue(attributeId)); // Compare the two dates returns negative value due to order var compare = -(dojo.date.difference(endDate, beginDate, "day")); if (compare>= 30) { // make sure endDate is not earlier than beginDate + 30 Ralph Schoon selected this answer as the correct answer
|
One other answer
![]()
Solved
|
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.