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

Deleted user April 24, 2016

Hello,

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?

https://developer.atlassian.com/static/javadoc/jira/latest/reference/com/atlassian/jira/issue/IssueManager.html#recordMovedIssueKey(com.atlassian.jira.issue.Issue)

 

Or shoud I realise the move-behaviour with the MoveIssueBean? Like I said, I hadn't found a working solution on google.
https://developer.atlassian.com/static/javadoc/jira/latest/reference/com/atlassian/jira/web/bean/MoveIssueBean.html

 

Thanks a lot!

Best regards

Michael

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 24, 2016

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 Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events