Ryan Palamara
ServiceNow Employee
ServiceNow Employee

Work Notes Synchronization for Remote Task is not supported Out Of The Box (OOTB) in Service Bridge. However there are situations where Providers want to be able to synchronize "Work Notes" in addition to the OOTB sync of "Additional Comments". Here is an example on how this can be done with custom Business Rules (BR). As a customization, this falls outside of product support and you will be responsible for maintenance and troubleshooting, but if there is the business need, this will help get you started.

 

The first BR is to be created on the instance that will be sending the Work Notes. The BR will be created on the task table that is the source in the Remote Task Definition. For example, if you are syncing from Incident on the instance, that is the table the BR will target.

 

The instance that wants to send Work Notes from the parent record:

 

When: Before/Update

Table: Incident

Condition:

 

 

gs.isInteractive() && current.work_notes.changes()

 

 

 

Script:

 

 

//Get worknote and add User/Date/Time/TimeZone

var wn = current.work_notes + '\n\n-- ' + gs.getUserDisplayName() + '\n' + gs.nowDateTime() + ' ' + gs.getSysTimeZone();

//Get the Remote tasks if there are any for this parent

var rt = new GlideRecord('[sn_sb_remote_task]');

rt.addActiveQuery();
rt.addQuery('parent', current.sys_id+'');
rt.query();
while (rt.next()) {
     rt.work_notes = wn;
     rt.update();
}

 

 

 

The second BR will run on the destination instance and will target the Remote Task table. This BR is not specific to the destination table, so will only need to be created once, even if there are multiple destination tables.

 

The instance that wants to copy the inbound Work Notes from the Remote Task to their parent:

 

When: Before/Update

Table: Remote Task

Condition

 

 

current.work_notes.changes() && new sn_sb.SBTransportUtilBase().isTransporterUser(gs.getUserName())

 

 

 

Script:

 

 

if (current.parent) {        
var parent = current.parent.getRefRecord();        
parent.work_notes = current.work_notes + '';        
parent.update();
}

 

 

 

As always, be sure to test!

5 Comments
JosipK
Tera Expert

Hi @Ryan Palamara, thank you for this, it works fine. I would just like to inform you that there are two incorrect entries:

1. The following code should be part of the script, not the condition:

//Get worknote and add User/Date/Time/TimeZone

var wn = current.work_notes + '\n\n-- ' + gs.getUserDisplayName() + '\n' + gs.nowDateTime() + ' ' + gs.getSysTimeZone();

2. There is an extra square bracket ] in the following line:

var rt = new GlideRecord('sn_sb_remote_task]');

 

Ryan Palamara
ServiceNow Employee
ServiceNow Employee

Thank you @JosipK ! Updated in the post.

Ty Steels
Tera Contributor

Does this work bi-directionally? Example - I send a work note in the provider instance and it sends to the consumer. Then the consumer responds with a work note and comes to the provider.

Ryan Palamara
ServiceNow Employee
ServiceNow Employee

Hi Ty, it does. Note that you will need to add the logic on both sides. The first BR is setup on the instance that is sending the Work Notes and the second is setup on the instance receiving the Work Notes. So for Bi-directional you would setup both BRs on both the Provider and Consumer. 

tommccloud
Tera Contributor

Thanks for this, Ryan!

 

It's worth noting that the square brackets in your update post:

var rt = new GlideRecord('[sn_sb_remote_task]');

Will cause the business rule to fail, and they need to be removed.