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

Hello,

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!

Thanks!

1 answer

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

Does https://scriptrunner.adaptavist.com/latest/jira/builtin-scripts.html#_add_remove_from_to_active_sprint 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(issue.id);
       	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?

Thanks, 

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 7 hours ago in Off-topic

Miscellaneous Monday - Where it all started.

Happy Monday everyone! If you're anything like me, you tend to think a lot about what the future looks like. What are my kids up to in 15 years? Have we solved for climate change? How could TVs poss...

23 views 3 1
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