Difference between return false and set abort action

Kannan Nair
Tera Contributor

I have created a business rule on CMDB table to restrict the user from creating a duplicate CI with Insert and stay.

var ciname=current.name;

  var gr=new GlideRecord('cmdb_ci');

  gr.addQuery('name',ciname);

  gr.query();

  while(gr.next())

  {

  gs.addErrorMessage('Record already present');

  current.setAbortAction(true);

  }

Instead of current.setAbortAction(true);, I have tried return false. It was throwing the error 'Record already present' as expected, but the record was created.

Why return(false) didn't restrict the CI creation, or what is the basic difference between     current.setAbortAction(true); and return false?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Sanker,



Return false does just that, - it returns false. It doesn't prevent additional business rules from running.



current.setAbortAction(true); stops the business rule and stops the system from continuing to run additional (higher order) business rules.


View solution in original post

7 REPLIES 7

Never mind.  I found the answer.  In my subsequent BR if have:

 if (!current.isActionAborted()) {...}

and that did the trick!

OK, but what if there are 100 business rules already sitting out there in the system?

Say I'm adding business rule 101 at order 0...  I detect a condition that should absolutely HALT all subsequent processing.  Do I now need to go edit the existing 100 business rules and add a condition to check for isActionAborted?

Anurag Tripathi
Mega Patron
Mega Patron

hi Sanker,



Purpose is pretty much the same, return false is mostly used in client side to cancel/stop the transaction and Abort Action on server side for the same.


-Anurag