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

Is it possible to set setWorkflow(True) from transform map without checking Run business rule = true.

I dont want to run unnecessary business rule but I want audit should be generated in case records updated through transform map.

You can always use target.setWorkflow(true) in an onStart(), or onBefore() script and set it to false again onComplete() or onAfter().

Map with transformation event scripts

Hi Chuck,

I did the same thing, In before script, I added target.setWorkFlow(true) and in after script I added target.setWorkFlow(false) but its not working.

Could you please suggest some different option.

And even it this will work then it will run all business rule but I want to run aonly audit related business rule.

agopalrao
Mega Contributor

If the 3rd party updates uses a specific user, then you can trigger the business rule based on updated by field. If current updated by is a 3rd party rest api user then don't run the business rule.



OR You can introduce a 'is3rdPartyUpdate' as boolean and set to default false. In BR
if(current.is3rdPartyUpdate == true) {


  current.is3rdPartyUpdate=false


}else {


/// Your logic goes here...sending update to 3rd party tool


}


And before 3rd party api insert or update make sure to set this flag to true. (I am using this attribute to identify 3rd party updates.)



Hope this will solve the problem.


Hi Gopal,



Thank you for the suggestion, introducing a flag and maintaining its toggling can be tricky, but having a check in place for the user is interesting and in my case that can actually solve the problem. Thanks for your time



Regards