How to stop other business rules if the first business rule is aborted

alokims
Tera Contributor

Hi,

 

I have multiple before business rules with different orders. I want if any lower order business rule is abort then stop to execute all higher order business rule.

 

 

Thanks, Alok

8 REPLIES 8

Hi @alokims ,

 

Please refer this link which will tell you how setWorkFlow work. Set workflow 

 

If my response helped then please accept the solution and hi thumbs up.

Hello @alokims  

Change the order of code - 

 

current.setWorkflow(false);
current.setAbortAction(true);   
 
It's not working because you have already aborted the action. First "set Workflow" as false so that nothing else is running and then abort. 
 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Chaitanya ILCR
Kilo Patron

Hi @alokims ,

 

why do you want to this do you have any logic on the before BR?(example: altering other tables data in one of the before BRs?)

I would say move that logic to async or after BR 

 

I have tried setWorkflow(false) looks like it only stops the action which are triggered by the current action made on the database since setAbortaction is not going to trigger a different transaction the current transaction's before BRs are being evaluated

 

you can create a new field (isAborted something like this true/false field) you can set this to true in the BRs where you have used the setAbortaction and update(add) the other higher order BRs conditions with isAborted = false

 

this is just a suggestion.

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Ankur Bawiskar
Tera Patron
Tera Patron

@alokims 

that's not going to happen.

Why not combine those multiple before BRs into single one?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader