Stop a Business Rule from executing

thisisauniqueus
Giga Expert

Hi,

I have a setup where i am receiving REST request from 3rd party, i have used scripted REST API, and in response to incoming request i create/update a Demand ticket. So far so good. For send back updates i have created an update BR and using REST Message to send the updates back to 3rd party.

The problem is when the 3rd party sends an update request the BR is also triggered which should only be triggering when the updates are made in my instance. I have tried using

gr.setWorkFlow(false);

in the script to update the ticket from 3rd party, but that stops the additional comments and all the journal input fields to be updated, because i guess the journal fields are populated using a BR too. So my question is how can i make the BR to fire only when the update is made directly from the form NOT from the scripted REST API script?

Any help in this regards is appreciated. Kindly let me know if you need any additional information.

Regards,

JS

20 REPLIES 20

Chuck Tomasi
Tera Patron

If you want to stop a business rule from running, take a look at the



setAbortAction(true) option.



https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_GlideRecord-setAbortAction_Boolean


Thanks Chuck for your time.



In the BR how can i determine that the update was initiated from the script and not from the update button or the form. That the issue



like in the transform maps there is a check box "Run Business Rules" and if set to false the BR do not trigger   and yet the additional comments are added. How can i achieve the same in my script.



Regards,


JS


If you don't want business rules to run on a record, then your original idea of setWorkflow(false) is going to provide that. setAbortAction(false) says "STOP, right now and don't continue."



To determine if a user is involved, you can use gs.isInteractive(). It returns a true if there's a browser involved with triggering something or false if it was initiated by the system in the background.


Thanks



I have tried using the setWorkFlow(false) but it stops from updating the additional comments e.g.



...


gr.comments = "test";


gr.setWorkFlow(false);


gr.update();



this does not update the additional comments.



Regards