Combine the Run Action rules and the Run Scheduled Action rules

In Service Manager, the Run Action rules are executed in a sequential manner. Take the related records as an example, if one of the rules sets or actions against the related records fails, the whole execution stops and return a failure result. To ensure successful execution, you can combine the Run Action rules and the Run Scheduled Action rules, so that the execution can be scheduled if it fails due to record locking.

In the out-of-box configuration, when the status of an incident changes, the status of the related interaction also changes accordingly. To achieve this, a rule set “im.sync.status.to.interaction” is configured in the “After successful update” event of the Incident workflow, as shown below:

This rule set is configured on the "probsummary" table that stores incident records:

In addition, you also need to configure the Run Action rules in the rule set as follows:

  • Name the condition something like "Sync Interaction Status", which makes it easy for you to understand the purpose of the condition
  • Select Related Records for the "Run Action on" field
  • Select Escalate From Interaction for the "Relation Type" field. This means the target related record is the interaction from which incident is escalated.
  • Select sd.sync.status.from.escalation for the "Run Rule Set" field. This rule set is executed against the related interaction. To handle the operation failure on locked interaction, this rule set must contain the Run Scheduled Action rule.
  • Select Do nothing for the "Action after Rule Set" field. Actions like the save operation on target records are configured in the “sd.sync.status.from.escalation” rule set.

The form on which you can perform these tasks is shown below:

After defining the rule set on the source table, you need to define the rule set on the target table. The rule set on the target table is used as the value of the "Run Rule Set" field when you define the rule set for the source table. In this example, you define the rule set “sd.sync.status.from.escalation” on the target table “incidents” that stores the interaction records:

In this rule set, a Scheduled Action rule is configured to sync up the status of the incident and the status of the interaction. The configuration is as follows:

  • Specify the scheduled execution time as the current time by using JavaScript. This ensures the schedule is executed as early as possible, that is, it is executed the next time the back end scheduler “Scheduled Action processor” is activated.
  • Select Escalate From Interaction as the Relation Type. This means the target related record is the interaction from which the incident is escalated.
  • Specify the Action condition to call a JavaScript method StatusSyncServiceBeanWrapper.callBeanMethod("setSyncStatus",$L.file). All the main logic is included in this JavaScript method.
    • If status synchronization is needed and successful, this method returns true, and then the Save action is executed.
    • If status synchronization is not needed, this method returns false, and then the Save action is ignored automatically.
  • Keep the Run Rule Set field empty.
  • Select Save for the "Action after Rule Set"field. While the record is saved, if it is locked, the saving operation fails, and a schedule record is rescheduled instead of being deleted.
Note: Variables, which are referred to as srcRecordfor the current source record and as oldSrcRecord for the original source record in JavaScript, are not supported if the Run Scheduled Action rules are used.