Setworkflow(false) for specific business rules

nithin_s
Tera Contributor

I have a business rule which updates the values in a particular table (let's say Table A) after a record is inserted in the same table. I have a before insert which calculates and sets the value. I have an after update which recalculates if values are changed. There is another after update which sets the values. I want my setworkflow(false) to disable only one of the business rules

2 REPLIES 2

Ricardo26
Giga Guru

Hi,

 

I don't think it's possible to prevent specifics business rules to run.
In my option, the best scenario would be to use only before business rules to do the calculations, unless they are very time consuming. This would prevent any loop to occour.
You can also have all you business rule logic grouped in one single business rules that runs on the update, and in the code itself check which field has changed and apply the right sequence of calculation.

nityabans27
Kilo Patron

Hi @nithin_s,

setWorkflow(false) disables all business rules and flows — you can’t target just one.

✅ Fix:
Add a guard condition in the specific BR you want to skip, like:

if (gs.getSession().getClientData('skip_my_br') == 'true') return;

Then set that flag before your update.

Alternatively, use a custom flag field (u_skip_br) in the record to bypass that BR only.