I have finished a big part of the synchronization that we need for the Proof of Concept (actually everything that’s incoming to Jira from service-now). However, I am facing difficulties with the service-now incoming part. Particularly with comments. As an example of the problem, in attachment. What I am trying to do is to add a comment in Jira and for it to be synchronized in S-Now in the “Internal work notes” field. This is sort of happening, but it is not adding the latest comment only; it’s actually adding the full history of the comments each time.
I hope this finds you well and apologies for the slight tardiness in replying. In our call last week, you were able to articulate the requirements as follows:
Any comments coming in from Jira should appear as Work Notes in ServiceNow
Any changes made to the Summary (and other fields) on Jira after the first sync, should not reflect in the corresponding field on ServiceNow side, but should rather log a comment showing this change as a Work Note.
I was able to achieve the above with the following configuration:
if(firstSync){
//Decide on the first sync, which entity you want to create based on the remote issue type
entity.tableName = "incident"
entity.short_description = replica.summary
}
if(entity.tableName == "incident") {
entity.description = replica.description
entity.attachments += replica.addedAttachments
if(!firstSync && previous?.summary != replica.summary){
issue.comments = commentHelper.addComment("New description is now: " + replica.summary, false, issue.comments)
}
issue.comments = commentHelper.mergeComments(issue, replica, {it.internal = true})
}
A more detailed explanation of how this was done is contained in the following video: