You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!


Get the Visibility of New Comments in Jira Service Desk


Comments on Jira Service Management can be public (shared with the client) or private (internal comments). With this script, you can retrieve the visibility of a comment using a ScriptRunner Custom Script Listener.


As a project manager, I want to perform actions based on the issue comment visibility in Jira Service Management. For instance, I want to perform some automated task, like create a new comment, when an internal comment is created.

Good to Know

  • This script is a ScriptRunner Custom Script Listener.
  • To make it work you must configure the Issue Comment Edited or Issue Commented events.


  • Jira Service Desk Jira Service Desk (3.10 - 4.6)
  • ScriptRunner for Jira ScriptRunner for Jira (5.6.14)
import import com.atlassian.servicedesk.api.comment.ServiceDeskCommentService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.comments.Comment import groovy.json.JsonSlurper import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin @WithPlugin('com.atlassian.servicedesk') @PluginModule ServiceDeskCommentService serviceDeskCommentService final SD_PUBLIC_COMMENT = 'sd.public.comment' def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService) // check if the comment is a public service desk comment def isInternal = { Comment c -> def commentProperty = commentPropertyService.getProperty(loggedInUser,, SD_PUBLIC_COMMENT).entityProperty.orNull commentProperty ? new JsonSlurper().parseText(commentProperty.value)['internal'] : false } //The comment visibility value is true when the comment is internal and false when the comment is public def commentVisibility = (event.comment) ? isInternal(event.comment) : false //in this point, you can do anything with this value. For example: Create a new public comment when the created comment is not public if (commentVisibility) { def createCommentParameters = serviceDeskCommentService.newCreateBuilder() .author(loggedInUser) .body('I have written a private comment') .issue(event.comment.issue) .publicComment(true) .build() serviceDeskCommentService.createServiceDeskComment(loggedInUser, createCommentParameters) }
Discovered an issue? Report it here

Suggested for you