Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Jira Service Desk Scriptrunner - change collaborator comment to external

Using examples from the Scriptrunner site I have the following code, it runs just fine but the comments are still not showing up on the Portal. 
We need to be able to do this otherwise Service Desk is useless for collaborative work within our company. As is, Agents will have to Copy collaborator comments and re-add them as new comments just to make them show up or programatically do it, either way you end up with duplication which is pointless.


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.util.json.JSONObject
import groovy.json.JsonSlurper
import org.apache.log4j.Logger
import org.apache.log4j.Level

final SD_PUBLIC_COMMENT = "sd.public.comment"

def projectManager = ComponentAccessor.projectManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)

def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
def commentManager = ComponentAccessor.getCommentManager()

def event = event as IssueEvent
def user = event.getUser()
def projectRole = projectRoleManager.getProjectRole('Service Desk Collaborators')
if (projectRoleManager.isUserInProjectRole(user,projectRole,event.issue.getProjectObject())) {
def comment = event.getComment()

def isInternal = { Comment c ->
def commentProperty = commentPropertyService.getProperty(user,, SD_PUBLIC_COMMENT)

if (commentProperty) {
def props = new JsonSlurper().parseText(commentProperty.getValue())
else {

def jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext()
def originalUser = event.getUser()
try {
def userManager = ComponentAccessor.getUserManager()
def curAssignee = event.issue.getAssignee()
def agentUser = curAssignee "Assignee - ${curAssignee}" "original user - ${originalUser}"

if (comment && isInternal(comment)) {
def properties = [(SD_PUBLIC_COMMENT): new JSONObject(["internal": false])]
commentManager.update(comment, properties, true)

} finally {


2 answers

1 accepted

0 votes
Answer accepted

Hi @Jon Starbird i did a few testing about this. It seems that the public comment are only allowed to user having Service Desk Team role or Administrator role and only if the user have an Jira Service Desk licenses. That means that if an Service Desk Agent o Project Admin  (who have this kind of license) tries to update comments from users who dont have this roles in the project, even manually, it wont change to Public.

The only work around I found, is deleting the comment added by the Collaborator, and create new one with the agent user.

This is the code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.util.json.JSONObject
import groovy.json.JsonSlurper

ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)

IssueEvent event = event as IssueEvent
ApplicationUser user = event.getUser()
ProjectRole projectRole = projectRoleManager.getProjectRole('Service Desk Collaborators')

if (projectRoleManager.isUserInProjectRole(user, projectRole, event.issue.getProjectObject())) {

final String SD_PUBLIC_COMMENT = "sd.public.comment"

CommentPropertyService commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
CommentManager commentManager = ComponentAccessor.getCommentManager()
Comment comment = event.getComment()
ApplicationUser curAssignee = event.issue.getAssignee(),
agentUser = curAssignee

Closure isInternal = { Comment c ->
EntityProperty commentProperty = commentPropertyService.getProperty(user,, SD_PUBLIC_COMMENT)

if (commentProperty) {
def props = new JsonSlurper().parseText(commentProperty.getValue())
} else {

if (comment && isInternal(comment)) {

LinkedHashMap<String, JSONObject> properties = [(SD_PUBLIC_COMMENT): new JSONObject(["internal": false])]
String newComment = comment.authorFullName + " wrote: \n" + comment.getBody()
commentManager.create(event.issue, agentUser, newComment, null, null, new Date(), properties, true)



  I created a new comment adding the original author to have better visibility.

Hope it helps, is the better I could think to solve it.


thanks. Appreciate the help.

Wish there was a better solution but this will serve the purpose.

Like Alejandro Suárez likes this

Sorry for the edits, but i found that even if the users are in that roles, if they dont have Service Desk license, you cant change it to public.

You can test it trying to manually update a comment with an agent from a non agent.

sorry for the accept/unaccept/accept again there. Was having an issue with the browser and my mouse and got some clicks unintentionally in there.

Anyway, I ran this and it didn't work. The assignee is definitely an agent and the event user is a collaborator but it just doesn't work.

I don't get any errors, just doesn't do the delete and re-add. 

The agent user has permissions to delete all comments and the collaborators can delete their own comments,  checked that just in case.

@Alejandro Suárez [Tecnofor]  I marked unaccepted in case you had stopped watching the issue. 

As I noted above the code isn't working. I did note an additional oddity besides what I said above. It appears to be triggering the Comment event again as emails go out about the comment being added twice. But in both cases it's the same owner of the comment, the collaborator. In the Jira it doesn't show an extra comment. 

Hi @Jon Starbird, In my tests I created the role "Service Desk Collaborator" and added a random user to it. This user only have a Jira Software license.

The agent is in the Service Desk Agent Role, having a Service Desk license, and I added him to the assignee field.

With the same script I posted it worked for me adding a comment with the collaborator user. I asume that the agent has the create comment permission.

yes that is exactly what I have as well and yes I did verify all the permissions. 

The roles already exist but the users are part of them, via Jira groups.

Did you have it triggering on the Issue Comment or were you using the Service Desk Comment event? 
I am using the Issue Comment event.

Im using the Issue Comment as well, this is my listener.

Here is my listener: 

This i how i configured the roles:

And finally this is my permission scheme:

And this is the result:


This is the ticket in the portal:

that is exactly how I have it setup as well. I just used the code you gave me, didn't modify it at all.

The only difference is that for the Roles I have groups assigned there not specific users. But the users involved are in the appropriate groups.

The Agent is valid, he works other tickets. The collaborator is valid otherwise he couldn't comment on an issue from within Jira itself which is where I had him doing it from like our devs would.

We are using Jira Server 7.10.2 and Service Desk 3.13.2.

Hi @Jon Starbird I just did the same, and added te same users to different groups, and then added the groups to corresponding project roles.

It's working for me. Im using Jira Server 7.12.3 and Service Desk 3.15.3 and I dont know if thats relevant or not in this case. 

I'm sorry I can't help you further :(

@Alejandro Suárez [Tecnofor] understood. Thanks for all your help.

@Alejandro Suárez [Tecnofor] I've finally gotten our test server upgraded and we are now on Jira 8.1.0 and Service Desk 4.1.0 but this code still isn't working.

For some reason it isn't getting the comment properties so it cannot tell if it is Internal. I've added some debug statements and it is at that point it just isn't getting anything back for the properties.

I also tried changing it to use the agentuser to read the properties but that also didn't work.  

I did look at Adaptavist's site and the code is basically what you have so not sure if something has changed in the API's.

I found the issue. By default Collaborator comments are not marked as Internal so the value is Null preventing your code from working.

What I did was just check for the user to be a collaborator and then also checked to make sure they are not the reporter. Then do the rest skipping the check for internal or not. 

I find it odd that Service Desk doesn't mark Collaborator comments as Internal but perhaps there is a different flag there to be used. 

Overall I find Service Desk to be extremely flawed and it just make it useless to any company wanting to use it internally only, so pretty much any IT/IS desk IMO. I think it may work fine for anyone using it for external uses for customer support but they should quit trying to sell it as an IT/IS service desk solution, it isn't.

I've wasted so much time just hacking around it's inadequacies.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events