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

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

Add Comments to Service Desk Linked Issues


Hi, I created a comment listener when a user adds a comment to an issue, the listener adds the same comment to the linked issue. It is working fine with Jira software projects, I tested with two Jira Software projects. However, it's not adding comments to Service Desk linked issue. There is a service desk issue link to the Jira software issue. I want to be able to add comments in Jira software and it should be added to the Service Desk issue too but it's not working with SD. Any idea why it works with Jira software but won't work with Service Desk? What I'm missing?

import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.user.ApplicationUser;

CommentManager commentMgr = ComponentAccessor.getCommentManager()
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser

def issue = event.issue
def lastComment = commentMgr.getComments(issue).last().body

def links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())

def output = ""
for(l in links) {
output = output + + ": " + l.getDestinationObject() + "<br/>"

commentMgr.create(l.getDestinationObject(), currentUser, lastComment, false)

Thank you for your help.

1 answer

Unfortunately, I can't help you with your code, but I have a script like this in my Jira SM project. Maybe it will be useful to you and you can find a solution.


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


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()
.body('I have written a private comment')
serviceDeskCommentService.createServiceDeskComment(loggedInUser, createCommentParameters)

Thank you @Thomas for responding. I copied and pasted your script in the console to test the script, it is not working. I'm getting errors. I'm attaching screenshots. Any idea why?


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

95 views 1 6
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