How to use 'recordMovedIssueKey' in ScriptRunner? (Move Issue)


I'm new with ScriptRunner and Groovy and I try to create my first post function script. I want to move an issue from one project to another - I haven't found a working solution on google. My idea is to "simulate" this behaviour - 1.) create a clone issue per ScriptRunner 2.) copy history from old issue 3.) delete old issue 4.) set link from old issue to new issue. But I fail with the history and the link from the old issue to the new one.

Is this the right way to create the link (see link below)? Does anyone have an example how to use it?


Or shoud I realise the move-behaviour with the MoveIssueBean? Like I said, I hadn't found a working solution on google.


Thanks a lot!

Best regards


1 answer

0 vote

I think there's a logical flaw in here - "4.) set link from old issue to new issue." - a link has an issue at both ends.  But you've deleted the original issue.  So you can't link to it.  Even if you linked before delete, the deletion would clobber the link you've just created.

"Move" in JIRA is hard - the move functions have to check that all the data in the source issue matches the configuration for the target.  This means checking all the fields, and things that aren't really fields (and are hence a lot harder - status and issue type for example), and it's often impossible to automate because there's no actual logic for a move - you have to ask the user what they really want.

That said, if the config for source and target is the same, or you can make assumptions about equivalence (e.g. field X is mandatory in the target, but your move code is allowed to assume "pick option 3 if X is blank in the source"), you can code for proper move, and yes, use MoveIssueBean.  That will handle most of the work, including keeping the history.  It'll also preserve all the comments too.

Your "clone and copy history" idea is another good way to do it, but you're still going to need to think about the configs, history, comments and the rest.  I'm not sure it's better than trying to use the MoveIssueBean.

Suggest an answer

Log in or Join to answer
Community showcase
Emilee Spencer
Published 8 hours ago in Marketplace Apps

Marketplace Spotlight: DeepAffects

Hello Atlassian Community! My name is Emilee, and I’m a Product Marketing Manager for the Marketplace team. Starting with this post, I'm kicking off a monthly series of Spotlights to highlight Ma...

30 views 0 3
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot