Post comment with the ticket number after initial sync

Originally asked by Adriano Mazi on 29 December 2020 (original question)


I have a connection between Jira Server and Jira Service Desk and I’m trying to create a configuration that will post a comment (with the ticket number) on Jira Service Desk after the ticket on Jira Server has been opened.

I’m syncing the statuses between the tickets and added the comment information inside this part but it’s not working automatically, it only worked after I posted a comment on my ticket on Jira Server.

if (issue.type == nodeHelper.getIssueType(“Incident”)) {
def statusOpenMap = [“Open”:“Acknowledged”, “To Do”:“Acknowledged”, “In Progress”:“Acknowledged”] // [“remote status name”: “local status name”]
def remoteOpenStatusName = replica.status.name
if (replica.status.name == “Open” || replica.status.name == “To Do”) {
String syncissue_open = “Development ticket ‘${replica.key}’ has been opened”
issue.comments = commentHelper.addComment(issue.comments){ comment ->
comment.body = syncissue_open
comment.restrictSync = true
comment.internal = false
}
issue.setStatus(statusOpenMap[remoteOpenStatusName] ?: remoteOpenStatusName)
}


Answer by Adriano Mazi on 08 January 2021

I was able to find a configuration that works by creating a custom field called “Development Ticket” that will receive the ticket number and post a public comment afterwards.

if (!firstSync && issue.customFields.“Development Ticket”.value == null) {

// Post the ticket number in the custom field

issue.customFields.“Development Ticket”.value = replica.key

// Add a public comment that won’t be sync back

String syncissue_open = “Development ticket *${replica.key}* has been opened”

issue.comments = commentHelper.addComment(issue.comments){ comment ->

comment.body = syncissue_open

comment.restrictSync = true

comment.internal = false

}

}


Answer by Francis Martens (Exalate) on 08 January 2021

The way that Exalate works is that the incoming sync processor will be applied when receiving a message from the other side

The fact that it works when you make an update on the Jira Server is an indication that the incoming sync is behaving correctly.

So you need to find a way to trigger a message when the Jira Server issue is opened.
This can be done automatically using the SyncBackAfterProcessing approach.

On the Jira Server - in the incoming sync add something like

if (firstSync) {
   ...
   syncHelper.syncBackAfterProcessing()
}


Exalate will then trigger a sync back once that the message has finished processing …


Answer by Adriano Mazi on 08 January 2021

I’ve added this configuration and tested several other possibilities, but still wasn’t able to find a configuration that work. If I add the configuration inside the “firstSync” section, it does not work. If I add outside, I will post duplicate comments.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.