It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to check if sprint is active in behaviours



Using Behaviours - from Scriptrunner, I would like to check if a sprint is active. If that is true, then I would like to make a certain field (Story Points) read-only.


Please let me know how to check if the sprint is active.


Thank you!


This is what I have so far:


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.sprint.Sprint

def SprintField = getFieldById("Sprint")
def StoryPointsField = getFieldById("Story Points")

if (SprintField.state == Sprint.State.ACTIVE) {



1 answer

1 accepted

1 vote
Answer accepted

The "getFieldById" method from Behaviors returns a "formField" object. This is a scriptrunner/behavior class I think. Not a native class from Jira.

And the value stored in the formField is probably just the sprint Id.

So you'll need to get a customField object then lookup the value from the underlying issue.

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager

def sprintFormField = getFieldByName("Sprint")
def storyPtFormField = getFieldByName("Story Points")

def sprintCustField = customFieldManager.getCustomFieldObject(sprintFormField.fieldId)
sprint = issueContext.getCustomFieldValue(sprintCustField)

if(sprint && sprint.state == "ACTIVE"){
} else {

If you need to react to newly selected sprint values, then you'll need to fetch those details using the SprintManager.

Something along those lines may work:

import com.atlassian.greenhopper.service.sprint.SprintManager
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
SprintManager sprintManager

def sprintFormField = getFieldByName("Sprint")
def storyPtFormField = getFieldByName("Story Points")

def sprint = sprintManager.getSprint(sprintFormField.value as Long)
if(sprint.isValid() && sprint.value.state == "ACTIVE" ){

Thank you very much, this works great!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Portfolio for Jira

Program managers, we need your help! We want to learn about how you plan work for a team of teams

Hi community members, My name is Erika and I’m a product manager at Atlassian. We’re currently investigating how teams are planning work at the program level. We understand that every team in a tea...

145 views 0 5
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you