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

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

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

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')

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

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.

this question remains still open :(

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

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

78 views 0 5
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