Syncing comments in cloned issues

Rahul Aich [Nagra]
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.
April 7, 2016

Hi All

Is there a way to keep comments in sync between two cloned issues?

Rahul

2 answers

0 votes
Aleks Yenin (Polontech)
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.
April 7, 2016

You can solve it by using "Script Listeners" section of Script runner. Clone Issue and issue that was cloned should be linkedIssues. You can easily create a Custom listener triggered by the event "Issue Commented" and add a script similar to this one.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent;
 
public class CopyComments extends AbstractIssueEventListener {
 
    @Override
    void workflowEvent(IssueEvent event) {
 
        def linkedIssue = "TEST-1";
        def commentManager = ComponentAccessor.getCommentManager();
        def issueManager = ComponentAccessor.getIssueManager();
 
        def comment = event.getComment()
        def targetIssue = issueManager.getIssueObject(linkedIssue);
 
        commentManager.create(targetIssue, comment.authorApplicationUser, comment.body, true);
 
    }
 
}
0 votes
Jobin Kuruvilla [Adaptavist]
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.
April 7, 2016

You will need to write a listener to keep the comments in sync.

Suggest an answer

Log in or Sign up to answer