Business Rule sequence & execution

scot_sutton
Tera Contributor

If there exist 2 Business Rules run on the Approval [sysapproval_approver] table, the 1st with an Order = 100 and the 2nd with an Order = 200, both have the condition "current.state.changesTo('approved')" and the Script of the 1st BR is "current.setAbortAction(true);", will the 2nd BR ever be executed? If so, how can the running of the 2nd BR be prevented? This could be done using a variable set in the 1st BR but, unfortunately, the 2nd BR, of which I want to prevent execution, is an OOTB SN BR.

6 REPLIES 6

RKumar3
Tera Guru

Hi Scot,


when you user current.setAbortAction(true) in a business rules with smaller order, business rule with bigger order gets executed but action taken in this business rule does not get stored in database. So if you want to avoid the action taken by higher order business rule here, you are good as it wont be effective.



I tried it on my instance by writing 2 business rules(BRa & BRb) with same condition and first(BRa) with an order 50 while second(BRb) with an order 100. BRa has the condition to abort action. so when I make an update on an incident to fulfill the condition of both business rules, BRa executes and so does the BRb(i tested by adding a infoMessage) but changes made in BRb does not come into effect.


In theory setWorkflow(false) should be included in the 1st BR. Unfortunately, the problem is that the current.setAbortAction(true) statement in the 1st BR is not preventing the approval task state being set to "Approved" so including setWorkflow(false) in the BR before that issue is fixed causes other problems (associated group approval requests are not set to "No Longer Required"). Maybe I am looking in the wrong place for the cause of the approval task state update.


I'd look a the WF to run this and only a BR if needed.


Another way to try.


in BR1, as well as using a set AbortAction, try updating the scratchpad of the record / workflow.


get BR2 to read the scratchpad and stop if a specific value is set



Cheers


Anurag Tripathi
Mega Patron
Mega Patron