Business Rule sequence & execution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2015 04:51 AM
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.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2015 11:17 AM
Maybe if I am more specific someone will be able to assist.
I am attempting to prevent the approval of a task on the sysapproval_approver table if certain conditions are met. To this end I have a Business Rule with Order = 99 that executes gs.addErrorMessage and current.setAbortAction(true) statements when these conditions are met. I know that these are being executed because of the addErrorMessage.
The problem is that, even after the execution of the current.setAbortAction(true) statement, the state field of the approval task is being updated to 'approved'. The "Invalid update" message that usually appears when the current.setAbortAction(true) statement is executed is not being displayed.
Any insight would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2015 11:47 AM
I believe that I have discovered at a very high level the reason for this behavior. Apparently something downstream of the BR is getting the updated state set in the "Approve" UI Action that triggers the BR and using it in such a way that the approval task state field is eventually saved with the updated value of 'approved'. I say this because I inserted the line "current.state = 'requested';" into the BR after the "current.setAbortAction(true);" statement. The result is that if the specified BR conditions are met, the task state is not updated and the "Invalid update" message appears as expected.
My main question now is how is the functionality of the "current.setAbortAction(true);" statement being stopped so that the record is updated and the "Invalid update" message is not displayed?