In Salesforce, it is not uncommon to mass insert, update or delete records from time to time. This may be required to onboard new business units, departments or applications, fix bugs, patch existing records with certain values, accommodate changes in data model, archive and delete data etc.

But as we process data in bulk, validation rules and automation that are defined in Salesforce kicks in. This not only slows down the DML operation but may also lead to undesired processing like triggering emails to internal and external users, sending interface messages to backend systems and cause process and/or data integrity issues.

One of the ways around this problem is to deactivate these automations and validations, run your mass DML operations and reactivate. However, the challenge with this approach is that first it will require a downtime for your users and second it will take time and effort to deactivate and reactivate. This approach may be okay if these mass DML operations are not frequent, the number of validations and automations are not high, and your business does not mind a downtime. 

Bypass Automation & Validations in Salesforce for mass DML OperationsOr the second option will be to bake in some kind of mechanism in your solution to not to run these automations & validations for mass DML operations. Something like diverting heavy vehicles to take another route.

And this is where we can use “Custom Setting” of “Hierarchical” type in  Salesforce The benefit of using custom setting of hierarchal type is that you can define it at the org level and then override it at the profile level or user level. So for the scenario mentioned above, we can use a custom setting to bypass the validations and automations for a particular user and then use that user to perform mass DML operations.

In this step-by-step guide we will explore how to use the hierarchy custom setting to bypass validations and automations without impacting the normal operations. Like how to bypass. Like how to bypass:

  1. Validation Rules
  2. Workflow Rules
  3. Process Builder
  4. Salesforce Flows
  5. Apex Triggers

So, let’s grab a cup of coffee and dive in.



To download a PDF copy of the presentation above




check to receive weekly updates on more of such awesome guides





(You'll never be spammed on my watch. And that's a promise)

References & Useful URLs: