/* * "This script post function script provides an example of how to increment the due date by a number of weekdays specified. * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner * license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed * or amended and must be included in any circumstances where the code snippet is shared by You or a third party." */// Get the issue keydefissueKey=issue.key// Get today's date to set as the due datedeftoday=newDate()// Specify the number of weekdays to add onto todays datdefnumberOfWeekdays=<AddNumberOfDaysHere>// Add the specified number of weekdays onto the due dateif(numberOfWeekdays){// define a date object to updateDateresult=today;// Get the time value for todays dateDatenewDate=newDate(result.getTime())// Specify a loop counterinti=0;// Loop over for the number of weekdays to addwhile(i<numberOfWeekdays){// increment the date by 1 dayresult=result+1newDate=newDate(result.getTime())// Check if the date is a weekend and only increment the loop counter if it is notif(newDate[Calendar.DAY_OF_WEEK]==Calendar.SATURDAY||newDate[Calendar.DAY_OF_WEEK]==Calendar.SUNDAY){numberOfWeekdays++;}i++;}// Update the issue to set the due date to its new incremented valuedefupdateDueDate=put("/rest/api/2/issue/${issueKey}").header('Content-Type','application/json').body([fields:[// Set the due date to today's date in the format which Jira expects the date to be induedate:newDate.format('yyyy-MM-dd')asString]]).asString()}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.