Set the Due Date automatically based on creation date
Anand K (8●2●5)
| asked Apr 11 '18, 4:01 a.m.
retagged Apr 25 '18, 11:19 a.m. by Ken Tessier (841●1●7) I need to set the Due Date attribute automatically as X days ahead of creation date for Defect WI.
dojo.provide("com.example.DueDateProvider"); |
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered Apr 17 '18, 6:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Apr 17 '18, 6:58 a.m. Check https://jazz.net/library/article/1093 and check the last lab. Do some debug outputs to the console and read them.
/*********** * Licensed Materials - Property of IBM * (c) Copyright IBM Corporation 2011. All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: Anand K selected this answer as the correct answer
Comments
Anand K
commented Apr 18 '18, 1:19 a.m.
I got to know the problem was in work item type condition,
Anand K
commented Apr 18 '18, 1:22 a.m.
Now I updated the script to add 7 days without WI type condition. It works but while I create the WI, it shows default value in due date field as "Jan 8, 1970, 5:30:00 AM" which gets updated once I save the WI. Is there a way to show nothing when we just click to create WI?
Anand K
commented Apr 18 '18, 2:14 a.m.
In addition to default due date value, there is another issue that we can't change the due date to any other date. When I change it, while saving it reverts back to the calculated date (creation date + 7 days)
Anand K
commented Apr 18 '18, 2:14 a.m.
In addition to default due date value, there is another issue that we can't change the due date to any other date. When I change it, while saving it reverts back to the calculated date (creation date + 7 days).
showing 5 of 6
show 1 more comments
|
2 other answers
Ralph Schoon (63.5k●3●36●46)
| answered Apr 11 '18, 6:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER JavaScript provides ways like dojo.date to work with dates.
// 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)); |
I'm surprised to see so many mistakes in such simple script. Put it bluntly, of those lines that you need to modify and have modified from the example skeleton, none is correct (not just the calculation of date). I strongly suggest you read the API specification first before trying to write any codes.
Comments
Anand K
commented Apr 11 '18, 11:39 p.m.
Yes, you're right. I modified it from the example skeleton. I'm new bee to this, didn't have any idea where to refer to API's for it. Thank you for your suggestion.
Anand K
commented Apr 12 '18, 4:52 a.m.
I updated the script, but not getting how to set the Due Date attribute to some value. As of now I'm trying to set it to Creation Date value, later I'll modify to add 7 days. You can not set an attribute value in an attribute customization script. You can create a calculated value and return the value.
Anand K
commented Apr 17 '18, 6:04 a.m.
I changed the script to first set the Due Date attribute as of creation date only just to see if it reflects, but it's not happening. Please check the code;
Anand K
commented Apr 17 '18, 6:08 a.m.
I tried to return in this way also, but not working.
|
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.