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

Hi,

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?

Thanks

Julian

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.bc.issue.comment.property.CommentPropertyService
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, c.id, SD_PUBLIC_COMMENT)
        .getEntityProperty().getOrNull()

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

    false
}

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jun 14, 2018 in Jira Service Desk

How the Telegram Integration for Jira helps Sergey's team take their support efficiency to the bank

...+ reading Fantasy). The same is true for him at the bank he works for: Efficiency is key when time literally equals money. Read on to learn how Sergey makes most of the time he has by...

471 views 2 5
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