Script Runner - Clones an issue and links -> clone comments too

Peter Novak November 28, 2013

Hi there

Please can you help me, i want to clone all comments in this transition. How to do it? Some custom code? thx

3 answers

1 vote
RambanamP
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.
November 28, 2013

you mean, need to copy the comments from parent to cloned issue then try with this code

CommentManager commentMgr = ComponentAccessor.getCommentManager();
Collection<Comment> comments = commentMgr.getComments(sourceIssue);
for (Comment comment : comments) {
	commentMgr.create(clonnedissue, comment.getAuthor(), comment.getBody(), comment.getGroupLevel(),comment.getRoleLevelId(), comment.getCreated(), false);
}

make sure you have updated source and linked issue objects as per requirement

Peter Novak November 28, 2013

hi

this works with Groovy runner? i am using Script workflow function "Clones an issue and links" and there i can fill Additional issue actions. Please can you help me how to configure parent and cloned issue?

scr

i can see there this option:

issueInputParameters.setComment('Write your comment here')

RambanamP
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.
November 28, 2013

you have to replce the following objects

1. sourceIssue: it should be current issue object, i think you ca use as issue

2. clonnedissue: it should be clonned issue object, i am not sure how to get this

Hung Nguyen January 22, 2016

Peter,

Not sure if you could finally do it? I want to do the same thing but could not find out how to make it work.

0 votes
Hung Nguyen January 28, 2016

This one doesn't work, even after I changed 'clonedissue' to 'issue' in the script Rambanam provided below. Error Null pointer assignment somewhere.

0 votes
Peter Novak December 9, 2013

this question remains still open :(

Suggest an answer

Log in or Sign up to answer