/** This example script field script should configured to display on the 'Issue Sidebar' using a 'Text' return type and shows how to get the start date and end date from the active sprint and to display this inside a script field. * "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." */// Fetch the issue object from the key using the Jira Software APIdefissue=get("/rest/agile/1.0/issue/${issue.key}").header('Content-Type','application/json').asObject(Map).body// Check if the issue is in a sprint and if so if the sprint is an active sprintif(issue.fields.sprint&&issue.fields.sprint.state=='active'){// Get the sprint start and end date strings from the APIStringsprintStartDate=issue.fields.sprint.startDateStringsprintEndDate=issue.fields.sprint.endDate// Format the date strings into a nicer formatStringformattedSprintStartDate=sprintStartDate.substring(0,10)StringformatterSprintEndDate=sprintEndDate.substring(0,10)// Set the dates in the scripted fieldreturn"Sprint Start Date: ${formattedSprintStartDate} Sprint End Date: ${formatterSprintEndDate}"// Return a default message if the issue is not in active sprint}else{return"The ${issue.key} issue is not currently in an active sprint"}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.