[Script Runner] Example for Clone issue post function

Filip Håkansson September 23, 2014

I got some issue with post functions for clone issue. I would like to get some values from orignal issue.

The exemples provided gives me a hint to use  sourceIssue.*

Using for example issue.Summary = "Change: " + sourceIssue.summary 

gives me this error

[canned.jira.utils.ConditionUtils] Condition failed on issue: IVY-5, built-in script:com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue
java.lang.NullPointerException: Cannot invoke method contains() on null object
at java_util_List$contains$3.call(Unknown Source)
at Script16.run(Script16.groovy:1)

 

JIRA version 6.3.6

Script runner version: 3.0.5

Can you give some advice how to solve?

 

4 answers

1 vote
Geert Graat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 23, 2014

Hi,

Below are a few lines of code that I use to create a clone of an issue in the post function. Please note that issue is available in the post function scripts and refers to the current issue.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFactory
 
def compAccessor = new ComponentAccessor()
def issueFactory = compAccessor.getIssueFactory()
 
// define clone
def clone = issueFactory.cloneIssue(issue)
clone.setSummary("[SR] " + issue.getSummary())


Regards,

Geert

Michaela Gluchow October 13, 2017

Hi @Geert_Graat does this work as intended? I am looking for the right way to clone issues ;)

Cheers

Michaela

Geert Graat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 23, 2017

Hi,

I have used the code above successfully in the past, but currently we use the built-in clone an issue an links script as post action, which you can use without any coding.

Regards,

Geert

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2014

It should be: issue.Summary not issue.summary although I'm not sure that's your problem.

0 votes
Filip Håkansson September 23, 2014

Sorry, tag corrected and version information added to issue.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 23, 2014

Please use the correct label. What version of the plugin and jira?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events