Is it possible to create custom field called "Sprint Date Add" that will update automatically a date field based on the change in value of a sprint field.
Example: Issue created on 05/20/2016. Added to a sprint on 6/2/2016.
Sprint date add would then give a date value 06/02/2016.
This would be run for reporting purposes by a team that wants to know when an issue was exactly added to a sprint rather then checking the history tab of each issue. They want to be able to run a JQL and could use the Sprint Date Add to run a query based on that. It would visually also be good for reporting.
Hi Davor,
I have attached an example of how you can create a Scripted Field called Sprint Dates which will show for an issue what the Start and End dates for the sprint are.
I have attached below the code and config for the Scripted Field along with a screenshot of what the output on an issue looks like.
Code:
// Required Imports import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import java.text.SimpleDateFormat; import java.util.Date.*; // Get the current issue key Issue issue = issue // Get a pointer to the CustomFieldManager def customFieldManager = ComponentAccessor.getCustomFieldManager() // Get a pointer to the sprint CF def sprintCf = customFieldManager.getCustomFieldObjectByName("Sprint") // Stop the values on screen showing old cached values enableCache = {-> false} // Define a new Java Simple Date Format SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MMM/YYYY"); // Get the Start and End dates for the sprint Date startDate = issue.getCustomFieldValue(sprintCf)?.startDate?.first()?.toDate() Date endDate = issue.getCustomFieldValue(sprintCf)?.endDate?.first()?.toDate() // Format the dates with the Java Simple Date format defined def formattedstartDate = sdfDate.format(startDate) def formattedendDate = sdfDate.format(endDate) // Construct the output String to be returned String dates = "The Sprint Start Date is: " + formattedstartDate + "<br/>" + "The Sprint End Date is: " + formattedendDate // Return the output String return dates
Config:
image2016-6-7 11:13:3.png
Output:
image2016-6-7 11:13:27.png
I hope this helps.
Thanks
Kristian
Hi Kristian,
I am actually looking for a field that will show the date when the issue was added to the sprint. This would help on reporting on issues which are added after the sprint has started.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I try this with live issues that have been in more than one Sprint, I get the wrong dates.
e.g. for an issue now in Sprint 3, using
“endDate = issue.getCustomFieldValue(sprintCf)?.endDate?.first()?.toDate()”
gives me the end date of Sprint 1
Changing it to:
“endDate = issue.getCustomFieldValue(sprintCf)?.endDate?.last()?.toDate()”
gives me the end date Sprint 2
Any idea what syntax I need to get the end date of the current sprint (Sprint 3)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.