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

ScriptRunner: Add issue to sprint or change sprint for issue


I want to add an issue to a sprint (or remove it from one sprint and add it to another). Is there a way to do this using ScriptRunner?

Any help is much appreciated!


1 answer

Please use one of the ScriptRunner tags in future... 

Does not cover what you need to do? 

How can I use it in a ScriptRunner script?

Here is some background information:

We import data from aha and want to keep Fix Version/s and Sprint aligned, meaning our Fix Version/s and Sprints for a specific project have exactly the same names and exist already. aha just sets Fix Version/s, in JIRA we use Sprints. 

To keep them aligned automatically I added an issue updated listener, that recognizes either a Sprint or a Fix Version/s change in an issue ticket. If the Sprint value changed, Fix Version/s gets set accordingly. This works fine. I have the same logic in place in case Fix Version/s changes. Only getting the Sprint object fails. My approach was to get the Sprint through:

CustomField cf = customFieldManager.getCustomFieldObjectByName('Sprint');
def fieldConfig = cf.getRelevantConfig(issue);
def sprint = ComponentAccessor.optionsManager.getOptions(fieldConfig).find({ it == fixVersionName })?.first();

then set it with:

MutableIssue mutableIssue = issueManager.getIssueObject(;
       	sprintField.updateValue (null, issue, new ModifiedValue(issue.getCustomFieldValue(sprintField), sprint), new DefaultIssueChangeHolder());

Unfortunately I always get an empty option list...


The whole value change logic is in this script, thus it would be nice if it's also possible to handle the Sprint change for an issue there.

Thank you for the workflow function Jamie.  How can I make that fire one a ticket move event?

So I'm thinking about adding it to the Create workflow step as a post function.

I see it can take conditions.

What do I need to do to ensure that it only fires if the Create is a result of a Ticket Move event?


Randy James

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted 4 hours ago in Jira

Upcoming Enterprise releases targeting Q3 2019: Jira Software 8.5 & Jira Service Desk 4.5

Since launching the Jira Software 8.0 and Jira Service Desk 4.0 platform releases in February, many of you have been asking when the next Enterprise release will be so you can take advantage of the m...

170 views 0 3
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