Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the active sprint state in a misc calculated field

Mihai Mihai
Contributor
May 7, 2019

Hello,

 

Using the JIRA Misc Custom Field add-on, I would like to create a new field that returns "1" if the sprint of an issue is active, or "0" if it is anything else than active.

This is what I tried but it's not working:

 

<!-- @@Formula: String sprintState = issue.get("customfield_10005").getState().toString(); if (sprintState.equals("Active")) { return "1"; } else { return "0"; } -->

 

by sprint state I am referring to the "ACTIVE" state in the sprint properties':

 

com.atlassian.greenhopper.service.sprint.Sprint@4441e895[id=9153,rapidViewId=2963,state=ACTIVE,name=team1 test sprint,startDate=2019-05-07T00:00:07.164+02:00,endDate=2019-05-21T00:00:00.000+02:00,completeDate=,sequence=9153,goal=]

 

 

Thank you!

 

 

1 answer

1 accepted

1 vote
Answer accepted
David Fischer
Community Champion
May 7, 2019

issue.get("Sprint") actually returns a collection of Sprints: the active Sprint, plus all the closed Sprints the issue potentially belonged to before. To get the active sprint, use:

issue.get("Sprint")?.find{it.active}

For your need, it then becomes:

return issue.get("Sprint")?.find{it.active} ? 1 : 0

 However, this code requires JMCF 2.0 or better.

Mihai Mihai
Contributor
May 8, 2019

Thank you!

Matt May 24, 2019

Is there a way to do this pre-JMCF 2.0?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events