Async Business Rule and After business Rule difference with the example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 09:57 PM
Hi,
Please help me out with one example for
Async Business Rule and find the difference with the After business Rule.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 10:47 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 11:51 PM - edited 01-24-2025 11:53 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 12:17 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 12:58 AM
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".
- Create a new Business Rule on the incident table.
- Set the When field to Async.
- 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".
- Create a new Business Rule on the incident table.
- Set the When field to After.
- 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