Hello All,
When a subtask created then it should copy all the existing comments from the Parent issue. Also, I want to exclude comments made by Automation user.
I got an script but its showing error. Can some one help me with the correct script.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.Comment
def subtask = issue // Newly created subtask
def parentIssue = subtask.getParentObject() // Parent issue
// Get the automation user (change 'Automation User' to your actual automation user's name)
def automationUser = ComponentAccessor.getUserManager().getUserByName('Automation User')
// Get comments from the parent issue
def comments = parentIssue.getComments()
// Loop through comments and copy to the subtask, excluding comments made by the automation user
comments.each { comment ->
if (comment.getAuthor() != automationUser) {
ComponentAccessor.getCommentManager().create(subtask, comment.getAuthor(), comment.getBody(), comment.getGroupLevel(), comment.getRoleLevelId(), comment.getCreated(), null)
}
}