Async Business Rule and After business Rule difference with the example

kranthi2
Tera Expert

Hi,

Please help me out with one example for

Async Business Rule and find the difference with the After business Rule.

 

Thanks,

6 REPLIES 6

Viraj Hudlikar
Tera Sage

Hello @kranthi2 

 

The Async (asynchronous) and After (synchronous) are terms used to describe the execution timing of business rule. Understanding when to use each depends on the specific requirements of your business logic.

Async execution is after the database operation completes and the response is returned to the user.

After execution is executed immediately after the database operation is performed but before the response is sent to the user.

 

Also, check below video which will help you understand the concept of both with example showcased.
https://youtu.be/ILMemKPPRf0?si=M5aRYtl-OyHIfZ3X

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Servicenow Training Video demonstration is given for Async business rule in servicenow and difference between async business rule and after business rule in servicenow is also explained. I hope this video help you to understand the topic better. For notes you can navigate below link: ...

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @kranthi2 

Async Business Rules are similar to after rules in that they run after the database commits a change. Unlike after rules, async rules run in the background simultaneously with other processes. Async Business Rules allow ServiceNow to return control to the user sooner but may take longer to update related objects.

 

The best example is SLA calculation which runs Asynchronously. 

We use Async business rules so that user can interact with the form and the operation will be performed on the database Asynchronously. 

 

 

Please refer this video by @Runjay Patel 

https://youtu.be/VLwD4yt_AY4?si=eM0Eg66_1UmXgCsY

 

Please mark the answer as helpful and correct if helped. 

Kind Regards,

Ravi Chandra  

yuvarajkate
Giga Guru

After BR changes will be implemented immediately on the server after execution.

Async BR changes will be queued by the system and will implement the changes on the server when a free node is assigned to it by the system. It runs in the background.

Hope this cleared your doubt.

Juhi Poddar
Kilo Patron

Hello @kranthi2 

Here’s a detailed explanation and example of an Async Business Rule and how it differs from an After Business Rule:

What is an Async Business Rule?

  • Async Business Rules execute asynchronously, meaning they run in the background after the database operation is completed and do not block the current process.
  • They are primarily used for tasks that do not require immediate feedback to the user (e.g., notifications, logging, external integrations, etc.).
  • Async Business Rules improve performance and user experience because they allow the current transaction to complete without waiting for additional logic to finish.

What is an After Business Rule?

  • After Business Rules execute synchronously after the database operation is completed but before the user sees the result. They block the transaction until the rule completes its execution.
  • They are useful when subsequent actions depend on the outcome of the Business Rule, such as updating related records or enforcing data consistency.

Example of Async Business Rule

Send an email notification to the assigned user whenever the Incident priority is updated to "1 - Critical".

  1. Create a new Business Rule on the incident table.
  2. Set the When field to Async.
  3. Add this script:

 

if (current.priority == '1') {
    gs.eventQueue('incident.critical_notification', current, current.assigned_to, gs.getUser());
}

 

  • Define an Event called incident.critical_notification in System Policy > Events > Registry and attach an email notification to this event.

Example of After Business Rule

Automatically update the resolution_code to "Resolved by Support" when an Incident's state changes to "Resolved".

  1. Create a new Business Rule on the incident table.
  2. Set the When field to After.
  3. Add this script:

 

if (current.state == 6) { // Resolved state
    current.resolution_code = 'Solution provided';
current.resolution_notes = 'Add resolution notes here';
}

 

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar