+ Start a Discussion
Moshe BaitelmanMoshe Baitelman 

Can you use Apex to prevent process builder from running?

Hey all!

We have a process builder that is supposed to execute when a picklist field equals a specific option. When a user manually updates this picklist field or if I update it with Anonymous Apex, the process builder runs appropriately.

We also have a hourly batch job that often sets the picklist value. When the field is updated by the batch apex, the process builder does not run.

I have reviewed the execution order documentation (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm) and process builder documentation. 

I am not reopening the debate/conversation of PB vs Trigger. Question is: is there a way to use apex to prevent process builder from running? Is there a difference because this is batch apex? Has anyone ever come across something like this? Why would my process not trigger when the update happens via batch apex vs manual change?
 
Raj VakatiRaj Vakati
The only way you can do it on the user level create a checkbox that will show the bypass process builder .. if that checkbox is checked then you can skip the process builder .. 

https://ericsplayground.wordpress.com/2016/11/10/how-to-tell-process-builder-to-do-nothing/
Moshe BaitelmanMoshe Baitelman
Thanks Raj. I'm not trying to skip the process builder. I'm trying to figure out why my process is not triggering when changes are made via batch apex as opposed to when changes are made manually by a user.