In Scriptrunner, I am trying to create a Scripted Field for a Jira Service Management project.
The field will be fetching the date of the last public comment that was made by a user who is a member of a specific group.
Basically, I want to check if that comment is public or internal but I cannot get this information from the comment (com.atlassian.jira.issue.comments.CommentImpl).
I found this article by Adaptavist but I cannot adjust it in my script:
https://library.adaptavist.com/entity/get-the-visibility-of-new-comments-in-jira-service-desk
Any help on how to get the comment visibility and adjust it to the script below will be much appreciated:
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.commentManager
def comments = commentManager.getComments(issue).reverse()
def lastCommentDate = null
def groupX = ComponentAccessor.groupManager.getGroup("group-x")
for (comment in comments){
def author = comment.authorApplicationUser.username
// Here, I want to check if the comment is public or internal
if (ComponentAccessor.groupManager.getUserNamesInGroup(groupX).contains(author)) {
lastCommentDate = comment.updated
break;
}
}
if(lastCommentDate)
return lastCommentDate