How should I get sprint end date and do the comparison with other sprint's end date

Kris Han January 30, 2020

Hi all, 

As title, Is there any way which I can get sprint end date from story and do the comparison with another story's sprint end date? (prefer using Post-function or Script filed) Thank you very much!

 

Best Regards,

2 answers

2 accepted

0 votes
Answer accepted
Kris Han February 2, 2020

Hi @Leo ,

Thanks for your help. This script is work but can I ask one more question? How should I get the epic link's sprint end by using script? Thank you very much!

 

Best Regards,

Kris

Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 3, 2020

@Kris Han,

same as above script but instead of issue.{method} will have to fetch current issue's epic as issue and run sprint method as same as above script

I'll just post script to convert current issue's epic(if associated) as issue object

def issueManager = ComponentAccessor.issueManager

def epicLink = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Epic Link")

def epic = issue.getCustomFieldValue(epicLink) as String
if(epic){
def epicIssue = issueManager.getIssueObject(epic)

}

Let me know if you need assistance still

 

BR,

Leo 

Kris Han February 3, 2020

Hi @Leo ,

Thank you very much! It works.

 

Kris 

0 votes
Answer accepted
Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 31, 2020

Hi @Kris Han,

In Post-function you can use below code for getting sprint's end date

you can get it's state to verify whether it's active or not

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.greenhopper.service.sprint.Sprint

def cfSprint = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Sprint")
def currentSprint = issue.getCustomFieldValue(cfSprint) as List
def sp = currentSprint?.last() as Sprint
def endDate = sp.getEndDate()

 

here issue  is current issue on which transition happened

to work on another issue's date and fields use below code to get another issue object by using it's key and once you have both issues sprint end date you can make a comparison

def anotherIssue=ComponentAccessor.getIssueManager().getIssueObject("JIRA-12")

 

Hope this gives you some idea

 

BR,

Leo

Suggest an answer

Log in or Sign up to answer