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

Add Comments to Service Desk Linked Issues Edited

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 Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

129 views 1 1
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