BRs Running even after setAbortAction is true in BR running before them

BhupeshG
Tera Guru

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);

21 REPLIES 21

That's effectively what I said... Because they are both BEFORE rules, the setAbortAction() is only saying "Don't save this to the database", NOT "Don't run any more BRs."



I don't see this as a bug, just a design error and possibly a misunderstanding of which value to use in the "When" field on a BR.



Move that web service BR to an after (where it should be) and your problem goes away.


Hello Chuck — The BR2 cannot be written on After insert as I noticed that it does not capture Journal entry. For capturing Journal entry , only before insert is required?




With Regards


Bhupesh Gupta


I'd like to see the details of your webservice call on BR2... I wasn't aware of any issues getting the journal entry with getJournalEntry(1) to get that value.



Thank you for the detailed description and experiment above, that's exactly what I said would happen.



Akash mentioned setWorkflow(false). Be VERY careful when using this. Because it works on both BRs and Workflows, it can have unexpected consequences.


Dave Smith1
ServiceNow Employee
ServiceNow Employee

Bhupesh Gupta wrote:



This is what I received from HI support




Issue is reproducible on OOB instance. According to our documentation<http://wiki.servicenow.com/index.php?title=Scripting_in_Business_Rules#Aborting_a_Database_Action_in...>


Strange... I'd have thought they'd recommend a link to Docs, not to the Wiki!


We are on Helsinki version




With Regards


Bhupesh Gupta