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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot