Change an internal comment to external/shared with customer in Service Desk Using scriptrunner


we are using jira software and jira servicedesk on the same server, so we are able to move issues from jsd to software.

Everything works fine, but there is the problem, that in jira servicedesk when creating comments you can choose if it is an internal comment or you want to share the comment with the customer.

Jira software works not like this. in jira software we can select a (internal) group for which the comment is only shown.

when moving now a issue with internal comments from jira servicedesk to jira software project the internal comments are vissible for the customer.

is there a way to fix this?



1 answer

Hi Julian,

So a script that you could run from your script console and copy an internal comment from a service desk issue (SDP-2) to a jira project one (TAT-1) and make it visible only to jira-administrators will look like 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import groovy.json.JsonSlurper

def commentManager = ComponentAccessor.getCommentManager()
def issueManager = ComponentAccessor.getIssueManager()

def issueFrom = issueManager.getIssueByCurrentKey("SDP-2")
def lastComment = commentManager.getLastComment(issueFrom)

def issueTo = issueManager.getIssueByCurrentKey("TAT-1") as Issue
def isInternalComment = isInternal(lastComment)

if (isInternalComment) {
    commentManager.create(issueTo, lastComment.authorApplicationUser, lastComment.body, "jira-administrators", null, lastComment.created, false)

static boolean isInternal (Comment c) {
    final SD_PUBLIC_COMMENT = "sd.public.comment"
    def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
    def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
    def commentProperty = commentPropertyService.getProperty(user,, SD_PUBLIC_COMMENT)

    if (commentProperty) {
        def props = new JsonSlurper().parseText(commentProperty.getValue())
        return props['internal'].toBoolean()


Of cource you can change it in order to meet your requirements. 

Please let me know if this does the trick and if you have any further questions.

regards, Thanos

Suggest an answer

Log in or Sign up to answer
Community showcase
Published 16 hours ago in Jira

How you can achieve compact and easy-to-maintain workflows in your JIRA( Server)

This approach requires you to have the JIRA administrative rights. The main aim of this article is to help you achieve an organized, easy-to-maintain workflows in your JIRA instance thereby, reducin...

154 views 0 0
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you