andrew_och
ServiceNow Employee

The problem

 

With the SLA Engine set to asynchronous processing mode, task_sla records are created after the task is inserted/saved. So a user who opens a new incident and saves it or even updates will not see corresponding Task SLA records in the related list, even though SLAs are being attached in the background. As we know the related lists only update after a manual page refresh/reload.

 

incidentExample.png

 

The Fix

 

Using three pieces that work together:

  1. A business rule (SLA Engine Async scratchpad) runs before the form displays and copies the com.snc.sla.engine.async property into the scratchpad. The client can then tell whether async mode is on without a server round trip.
  2. A client script (TaskSLA Related List Refresh) runs onLoad. If async mode is on, it subscribes to an AMB channel for the current task's task_sla records.
  3. A Record Watcher on task_sla publishes a message to that channel whenever the SLA Engine inserts or updates a task_sla record for the task. When the message arrives, the client script refreshes the Task SLA related list.

taskSlaRelListRefresh.png

 

The majority of the work is done by the client script that you can see below.

 

SLA-refreshList.png

 

Both client script and business rule are attached to this article.