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.
Or 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:
- Validation Rules
- Workflow Rules
- Process Builder
- Salesforce Flows
- Apex Triggers
So, let’s grab a cup of coffee and dive in.
(We have discontinued our premium membership offering. If you are an existing premium member, you can still download the guides by clicking on “DOWNLOAD PDF [PREMIUM MEMBERS]” button. If you are not a premium member and want to download the guides, please sign up for our “All Access” pass. Complete details about this pass is available at this URL.)
References & Useful URLs
- Apex Developer Guide – Custom Settings
- Salesforce Help Article – Create Custom Settings
4 thoughts on “How To Bypass Automations & Validations in Salesforce for Mass DML Operations”
This is a very useful guide on how to implement a bypass for flows. Extremely valuable when you do data imports!
Thank you Ashish!
My pleasure Stephan. Glad that you like it. 🙂
On Slide 24, onmy end, Location field is greyed out. I tried to google the reason but most posts were about greyed out List option instead of Hierarchy. Do you have a wild guess why Location is greyed out?
Hi Javeria, Please refer to the Salesforce Article https://help.salesforce.com/s/articleView?id=000317370&type=1 for the details on why this is greyed out and how to enable this.