Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Latest Additional comments are not getting insync from case to Incident

saibandaru
Tera Contributor

Customer comments are not syncing with the incident from the case. The scenario is: when Customer One creates a case and adds additional comments, those comments sync correctly with the incident. However, when Customer Two — who has the same roles — adds a comment to the case created by Customer One, the comments do not sync with the incident.

- We haven't customized any script to restrict users from adding additional comments during the sync process. However, we have customized a script to ensure that all the latest additional comments are synced from the case to the incident, provided the comments are not identical.

 

- Script used for sync b/w case to incident:

 

(function executeRule(current, previous /*null when async*/ ) {
    // Add your code here
    var inc = new GlideRecord('incident');
    if (inc.get(current.incident)) {
        var workNotes = current.comments.getJournalEntry(1).split("(Additional comments)");
        var inc_notes = inc.comments.getJournalEntry(1).split("(Additional comments)");
        if (inc_notes[1] == undefined && workNotes[1] == undefined) {
            inc.comments += workNotes;
            inc.update();
        } else if (inc_notes[1].trim() != workNotes[1].trim()) {
            //cs.work_notes += "-" + workNotes;
            inc.comments += workNotes[1];
            inc.update();

        }
    }
})(current, previous);
5 REPLIES 5

@saibandaru 

please share what came in logs

what's the business rule condition?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader