Add internal note in Zendesk with GitHub reporters username

Originally asked by Sydney Hollingsworth on 24 August 2021 (original question)


I am trying to add an internal note to a Zendesk ticket on the first exalate sync that will add the username of the GitHub reporter and also the replica.key. Here is what I’m trying:

//add note about github username
if (firstSync) {
def github_username =
github_username = nodeHelper.getUser(replica.reporter?.username)
issue.comments =
comment.internal = true
comment.body = github_username + replica.key
}

I am getting the following error:

**Error impact:**Relation

**Error type:**Incoming script error

For input string: “{this is the github username}


Comments:

Ariel Aguilar commented on 24 August 2021

Hi Sydney,

Maybe you can try

Incoming Zendesk:

if (firstSync) {
issue.comments = commentHelper.mergeComments(issue, replica,                     
            { it.internal = true
            comment ->
            comment.body = "Reported by user: " + 
 replica.reporter.username + " and reference key: " + replica.key
			comment 
                    }
)
}

Kind regards,

Ariel

Sydney Hollingsworth commented on 27 August 2021

Hi Ariel,

Thanks, copy and pasting this wouldn’t let me save so I edited to:

if (firstSync) {
issue.comments = commentHelper.mergeComments(issue, replica, { 
    comment ->
        comment.internal = true
        comment.body = "Reported by user: " + 
        replica.reporter.username + " and reference key: " + replica.key
        comment 
    }
)
}

Update: This does not work. Can you help further?

Ariel Aguilar commented on 27 August 2021

Hi Sydney,

Can you please try:

if (firstSync) {
issue.comments = commentHelper.addComment("Reported by user: " + 
        replica.reporter.username + " and reference key: " + replica.key, false, issue.comments) 
} else {
  issue.comments     = commentHelper.mergeComments(issue, replica)
}

Kind regards,

Ariel

Sydney Hollingsworth commented on 27 August 2021

Update:

if (firstSync) {
issue.comments = commentHelper.addComment("Reported by user: " + replica.reporter.username + "\n GitHub URL: " + issueUrl, issue.comments)
}

this seems to do the trick!

Ariel Aguilar commented on 27 August 2021

Ok great, I added the false statement since you may not want to add this comment to the replica, so if a new comment is added in Zendesk the just added comment won’t show on GitHub side, but only the new ones. Also, the else clause in case you want to make a second sync.

Kind regards,

Ariel