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

create ServiceDesk internal comment in scriptrunner is not working Edited

This sample code to create internal comment from Adaptavist scriptrunner sample defaults to creating external comment, which is not correct

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.util.json.JSONObject

final SD_PUBLIC_COMMENT = "sd.public.comment"

def commentManager = ComponentAccessor.getCommentManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def properties = [(SD_PUBLIC_COMMENT): new JSONObject(["internal": true])]
commentManager.create(issue, user, "my internal comment", null, null, new Date(), properties, true)

Can someone from Adaptavist help me know why this is happening?

1 answer

May I ask what version of JIRA & Service Desk you're using?

That sample code is consistent with our docs. Could you run the following script (change KEY-1 to a representative issue) in the Script Console and provide the log output?

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

final SD_PUBLIC_COMMENT = "sd.public.comment"

def issueService = ComponentAccessor.issueService
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def commentManager = ComponentAccessor.commentManager
def issue = issueService.getIssue(user, "KEY-1").issue

def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)

def isInternal = { Comment c ->
    def commentProperty = commentPropertyService.getProperty(user,, SD_PUBLIC_COMMENT)

    if (commentProperty) {
        def props = new JsonSlurper().parseText(commentProperty.getValue())
    else {

    log.warn("Comment on issue ${issue.key}, id: ${}, internal: ${isInternal(it)}")

You can elaborate those logs if more info would help provide context.

Jonny, thank you.



2017-04-20 21:48:27,668 WARN [runner.ScriptRunnerImpl]: Comment on issue CTT-53, id: 37958, internal: false
2017-04-20 21:48:27,669 WARN [runner.ScriptRunnerImpl]: Comment on issue CTT-53, id: 39108, internal: true
2017-04-20 21:48:27,670 WARN [runner.ScriptRunnerImpl]: Comment on issue CTT-53, id: 39109, internal: false
2017-04-20 21:48:27,671 WARN [runner.ScriptRunnerImpl]: Comment on issue CTT-53, id: 39111, internal: false
2017-04-20 21:48:27,672 WARN [runner.ScriptRunnerImpl]: Comment on issue CTT-53, id: 39113, internal: true
2017-04-20 21:48:27,672 WARN [runner.ScriptRunnerImpl]: Comment on issue CTT-53, id: 39115, internal: false
2017-04-20 21:48:27,673 WARN [runner.ScriptRunnerImpl]: Comment on issue CTT-53, id: 39117, internal: false


Now worth explaining what i am doing. I am propagating comments created on other linked issues to this Service Desk issue and i was expecting them to get created as private but they don't.

As you see the last comment in the logs (id: 39117) was created in the source issue but propagated here as not internal.


JIRA version: 7.3.0

Scriptrunner: 4.3.19

Hi Jonny,

Any thing from the logs i pasted above? I tried all possible tests but still this is not created as internal comment!

You guys keep saying on Adaptavist wiki, ask your questions in the atlassian community, ask the question in the altlassian community and here we are. No one came back with any help so far and it has been like 2 weeks or more since i asked this question.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 03, 2019 in Marketplace Apps

How to estimate projects more accurately?

Gaining insight into your team’s effectiveness and choosing the right estimation technique.   Estimating projects is hard. It is because people have the tendency to underestimate the time thin...

280 views 2 8
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