How can I delete a specific comment from an issue based on the comment id with Scriptrunner? Example: Delete from Issue 10 Comment 223
Hi,
this thread should help you
https://community.atlassian.com/t5/Jira-questions/How-to-delete-user-comment/qaq-p/979266
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
here is the code that is actually working for me; could be better but does the job:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
String issueKey = "AB-1234"
Integer commentID = 1234567
IssueManager issueManager = ComponentAccessor.issueManager
CommentManager commentManager = ComponentAccessor.commentManager
MutableIssue issue = issueManager.getIssueObject(issueKey)
List<Comment> comments = commentManager.getComments(issue)
comments.each {comment ->
if (comment.id == commentID) {
commentManager.delete(comment)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.