Sprint Date Custom field

Davor Fisher June 3, 2016

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.

1 answer

2 votes
Kristian Walker (Adaptavist)
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 7, 2016

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

Davor Fisher June 14, 2016

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.

stuart_urquhart_l3t_com
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 11, 2016

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)?

Suggest an answer

Log in or Sign up to answer