Saura Sambit
Tera Expert

In the ServiceNow ecosystem, we frequently encounter the requirement to synchronise journal field entries, such as Work Notes or Additional Comments, between related task records. The most straightforward approach is to use business rules. This method works well for unidirectional synchronisation. However, when synchronisation needs to be bidirectional, duplicate journal entries begin to appear due to recurring triggers of the business rules.

 

Over the years, various approaches have been employed to address this issue, including the creation of custom checkbox fields, setting workflows to false, and several others. While these methods are effective, they often introduce some form of technical debt. In this article, we will explore a straightforward solution for achieving bidirectional synchronisation. Our method will not involve creating custom fields or disabling notifications and other updates by setting workflows to false.

 

    • Keep the below snippet in mind, we will be making use of this.
[code]<p DoNotCopy></p>[/code]

 

Requirement

 

When a Work Note is added to any Incident [incident] record,

      • copy the Work Note to the parent incident.
      • copy the Work Note to any child incidents.

 

Business rule configuration

 

      1. Navigate to Business Rules table and proceed to create a new rule.
      2. Set the values as follows -
        • Name - anything
        • Table - Incident [incident]
        • Advanced - true
        • When - before
        • Update - true
        • Filter Conditions - Work notes changes

 

copy_work_note_business_rule_record.png

 

       3. Under the 'Advanced' tab, the configuration should look something like below.

      • Condition -
current['work_notes'].indexOf('DoNotCopy') == -1
      • Script -

copy_work_notes_business_rule_script.png

 

 

How will this stop the recurring triggers?

 

In line 20 of the script, before copying the work_notes, we are adding a code snippet to it.

[code]<p DoNotCopy></p>[/code]

 

Since it is an empty HTML block, the code snippet remains invisible when viewing the work notes directly, but it can be detected through code. Therefore, the condition field on the business rule will check for this snippet's existence and prevent the business rule from being re-triggered.

      • Condition -
current['work_notes'].indexOf('DoNotCopy') == -1

 

Number of custom fields? Zero. setWorkflow(false)? Not needed.

Just keep adding a similar snippet and condition to the business rule whenever there is a need to copy journal entries automatically and there would be no duplicates.

 

The business rule can also run 'after' or 'async', we just have to access the journal fields like -

current.work_notes.getJournalEntry(1)

 

Next steps

 

Experiment by writing rules to copy journal entries across multiple tables, share among your peers.

Comments
Priyanka_1994
Tera Explorer

@Saura Sambit Thanks for sharing it. New thing to learn.

 

Regards,

Priyanka Salunke

Shilpa451
Tera Contributor

@Saura Sambit , We are facing the same issue in integration with Azure Devops. We have used REST message and scripted REST calls to make this integration. Work notes are getting duplicated. Can you help me how to avoid this? Thank you in advance.

MuthyamSai
Tera Explorer

Hi Saura Sambit

It's working fine parent to child and child to parent.

Is it possible for all child incidents under the same parent incident to view each other's work notes, and if so, how can this be implemented?

 
 
Mohammed Daiyan
Tera Contributor

Is this possible for CSM integration with Incident management, syncing the Case worknotes to INC worknotes and INC worknotes to case worknotes.
Also Case additional comments to INC add comments, and INC add comments to Case additional comments?


Version history
Last update:
‎07-31-2024 10:40 PM
Updated by:
Contributors