Sprint Date Custom field

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

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.

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,104 views 13 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot