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
Community showcase
Posted in United States

One week from next event!

We're having breakfast next Monday at 8AM.  We'd love to see you all come out!  Details and RSVP can be found at:

18 views 0 0
View post

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