Incoming comments on ServiceNow issue

Originally asked by Harold Oconitrillo on 17 March 2022 (original question)


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.


Answer by Syed Majid Hassan on 23 March 2022

Hi Harold,

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:

Jira to SNOW Work Notes.mp4 (old community)

Many thanks

Majid


Answer by Eileen Reimers on 17 March 2022

Hi

I haven´t found your problem 100% but the way how to add always the current comment is described in this documentation:

https://docs.idalko.com/exalate/display/ED/How+to+synchronize+comments

Hopefully this will help you

Regards, Eileen