BRs Running even after setAbortAction is true in BR running before them
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 05:29 AM
Hello Friends - I have BR X which run on Order = 50 and do the below stuff but I found even though I get error pop up saying invalid insert it does not stop another BR Y which is on order 100,000 . Therefore the WS call is made and data is sent to External integration for an invalid ticket.
Kindly advise how can stop this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(gs.isInteractive())
{
gs.addErrorMessage('Please assign this Incident to SNOW Group before assigning to External Group');
current.setAbortAction(true);
}
})(current, previous);
- Labels:
-
Integrations
-
Upgrades and Patches
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2021 12:03 PM
Although the Here is a solution that should prevent subsequent business rules from processing:
Scenario:
- Business Rule A is triggered when Status changes to Retired, order = 100; displays message “Business Rule A was fired”, then calls current.setAbortAction(true);
- Business Rule B is triggered when Status changes to Retired, order = 200; displays message “Business Rule B was fired”.
- Test: Change a CI status to Retired in a List View.
- Result: Status was reverted to Installed on the List View. Both messages were displayed, i.e. the second Business Rule was processed even though the first Business Rule was aborted.
Fix:
- In addition to calling current.setAbortAction(true), set current.install_status to previous.install_status.
- Test: Change a CI status to Retired in a List View.
- Result: Status was reverted to Installed on the List View. Only the Business Rule A message was displayed, i.e. the second Business Rule was NOT processed.
Conclusion: if you want to prevent subsequent business rules from processing specific changes, you should not only setAbortAction(true) but also revert the specific values of the variable current that would are conditions of the subsequent business rules. While the business rule itself will still be fired, the conditions will no longer apply if you change the attributes in current, so the actions will not be executed.
The opinions expressed here are the opinions of the author, and are not endorsed by ServiceNow or any other employer, company, or entity.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 01:44 AM
use if (!current.isActionAborted()) in next BR