Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script to change the comment visibility of an issue



Looking for a script to change the comment visibility of an issue in JSD.

The comments need to be hidden from the customer after doing a migration and import via csv file.



3 answers

We run across a very similar issue and the resolution/script was provided by Andy Heinzer in this thread.


  • Is it not possible to edit a comment once it is entered in JSM through a Rest API Call (which is what automations use to operate on JSM). So you need to control the visibility of the comment when entering it. Refer to this thread.
  • You can either enter a comment as a separate action through the automation UI, which allows you to set the comment visibility as follows: 
    comment visibility.png

  • Or use an API call to set your comment visibility for a JSM issue which looks like this:
    "update": {
    "comment": [
    "add": {
    "public": false,
    "body": "Ticket automatically resolved upon creation"
  • Nevertheless, if you are trying to set the visibility of the comment while entering it during an issue transition, or if you are handling issue in a non-JSM project, then you can't set the comment visibility via API calls. The only workaround is to add a public comment, and reduce it's visibility to a specific Jira Role/Group so other users cannot see it (in my case I reduce it to the Administrators role). The API call would look somehow like this:
    "update": {
    "comment": [
    "add": {
    "body": "Thanks for raising {{issue.key}}.",
    "visibility": {
    "type": "role",
    "value": "Developers"


    In this case, as Andy mentioned as well, you'd need to update the actor of your automation to a user that belongs to the Role/Group you are restricting the comment visibility to. The reason is that the standard automation user "Automation for Jira" is not part of that role and therefore cannot publish restricted comments to that role.

I hope this helps. Let me know if it doesn't 


Thanks for you reply, however, my problem is different in this because we need to change already existing comments.

These comments are created when importing issues via the CSV import and there it's not possible to set it comment to internal only.


So how can we change already existing comments using a groovy script?

This one did it for me:


import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.attachment.Attachment
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.jql.parser.JqlQueryParser;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.jira.issue.AttachmentManager;

def findIssues(String jqlQuery) {
def issueManager = ComponentAccessor.issueManager
def user = ComponentAccessor.getUserManager().getUserByKey("no-reply")
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchService = ComponentAccessor.getComponent(SearchService)
def query = jqlQueryParser.parseQuery(jqlQuery)
def results =, query, PagerFilter.getUnlimitedFilter())
def user = ComponentAccessor.getUserManager().getUserByKey("no-reply")
def jqlQuery = "project = sd10 and status = 'In Progress'"
def issues = findIssues(jqlQuery)
def commentManager = ComponentAccessor.getCommentManager()
def jsonManager = ComponentAccessor.getComponent(JsonEntityPropertyManager)

issues.each{issue ->
log.error("Changing comment visibility on $issue.")
// Get all comments
def comments = commentManager.getComments(issue);

for (def comment : comments) {
jsonManager.put(user, "", comment.getId(), "sd.public.comment", "{ \"internal\" : true}" , (java.util.function.BiFunction) null, false)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...

815 views 26 33
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you