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
11-29-2017 06:54 PM
function onSubmit() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('FIELD OR VARIABLE') == g_form.getValue('FIELD OR VARIABLE') )
{
alert("" );
g_form.submitted = false;
return false;
}
else{
return true;
}
}
Check this one

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2017 09:11 PM
Abort will stop all business rules running for that transaction and not update the record.
There may be another transaction that is causing the business rules to execute.
Have you tried turning on 'Debug Business Rules'?
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2017 05:24 AM
Chuck Tomasi wrote:
I agree, more experimentation is required. Let me know what you find.
Further experimentation performed, with interesting results. My test cases were three business rules:
- beforeInsert, order 100, set field A
- beforeInsert, order 200, set field B
- beforeInsert, order 300, set field C
Adding a new record had field A, B and C all populated.
Then I added a setAbortAction() to the middle BR. When trying to add another record, the following was observed:
- field A, B and C were all populated on the form
- an addErrorMessage() displayed, stating "invalid insert"
- the record was NOT saved.
Consequently, I deduce that setAbortAction(true):
- prevented the insert - although the form had fields populated, they weren't written to the DB
- does NOT stop further processing in that BR from running - field B still populated (abort was higher)
- does NOT prevent further BRs from processing - field C still populated.
Certainly the docs could be updated with some examples or clearer information. Anyone got further examples/experimentation to share?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2017 05:29 AM
Hi Bhupesh,
If you want to stop other business rules from running after some event, you could use "object.setWorkflow(false)", in this case, object would be current.
If you want to stop the current action i.e. update or insert you can use "current.setAbortAction(true)" in business rule, make sure you run this business rule onBefore.
You can also stop current action using OnSubmit client script where you could write something like:
if(<condition to stop>){
return false;
}
Akash
Hit like or correct if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2021 03:57 AM
Hi Developers,
I was also getting this type of error.
1st BR- (before): this BR was aborting at certain condition.
2nd BR (before): After execution of 1st BR wch aborted, 2nd BR was still executing.
Solution: I tried changing the order of both BR's but it didnt work. So I made the 2nd BR to run as after BR instead of before.
Hope this helps.
Regards,
Snehal