Creating an On-off Power Switch for Salesforce Automations

By Bart Lont

You can run into issues when importing data into Salesforce, as this kicks off automations such as Flows, Triggers and Validation Rules. Sometimes, you just want to import data without any interventions – or avoid any data import failures because it doesn’t meet the criteria in your automations.

Wouldn’t it be great to have a power switch to turn automations on and off, with just one click? In this guide I’m going to show you how you can do exactly that, taking advantage of custom settings.

READ MORE: How to Import Data Into Salesforce – Complete Guide

*Disclaimer: Creating an On/Off Power Switch is incredibly powerful and can have unintended consequences, for example, importing poor quality data. Automations and data validations are there for a reason. Before you import any data, you should ensure that it is thoroughly cleansed and suitable for import.

Step 1: Custom Settings

Go to Salesforce Setup → Custom Settings. Create a new custom setting:

  • Label: ‘Automation Settings’.
  • Object name: ‘Automation_Settings’.

Next, create custom fields based on which automations you want to control with the on/off switch. In this example I’ll create one for Validation Rules:

  • Click new, and select checkbox.
  • Field label: ‘Validation Rules Enabled’.
  • Default value: Checked.
  • Field name: ‘Validation_Rules_Enabled’.
  • Click next, and save.

Repeat this for each automation (e.g. Flow) and the result should look like this:

Custom setting created with two custom fields.

Step 2: Reference Custom Settings

With the checkboxes in place, it’s now time to reference them in our automations. This means that when a checkbox in the custom settings is checked, it will execute the automation – if it’s not checked, it won’t execute.

So if you have 12 Flows, add an entry to the resource in all 12. That should look like this:

‘$Setup.Automation_Settings__c.Flow_Enabled__c ‘ followed by whichever other criteria is needed.

Result: when the ‘Flow Enabled’ checkbox is checked in the custom settings, the Flows will be executed – if not, the Flows will not be executed. Within the Flow, you can find the Custom Settings fields under the Setup global variable.

Let’s do the same trick for Validation Rules. Add $Setup.Automation_Settings__c.Validation_Rules_Enabled__c && to the Error Condition Formula of each Validation Rule:

Custom settings reference added to the Error Condition Formula of the Validation Rule

Result: when the ‘Validation Rules Enabled’ checkbox is checked in Custom Settings, the Validation Rule might return TRUE, if not the Validation Rule will never return TRUE.

Read More :

Step 3: Turning On The Switch

The final step is to learn how to use the switch. Let’s return to the checkboxes we created earlier:

  • Go to Setup → Custom Settings. Click manage, then new or edit.
  • Check/uncheck the checkboxes (on or off), then click save.
Turning the checkboxes on or off.

Final Tips

Now, you have full control of which automations will/won’t execute when you import data in your org.

While the on-off switch is powerful, it can be risky. So, consider this advice:

  • Be disciplined in referencing the custom setting in all automations you want to control.
  • Automations are an essential part of Salesforce – don’t forget to turn them back on as soon as the data import is complete!

The Author

Bart Lont

Supports non-profit organisations using Salesforce. He also hosts a monthly Salesforce Saturday.


    January 20, 2021 10:13 am
    A great article. Apart from validation and workflow, see how to use a on off switch for Salesforce Flows here on Accidental Coder Blog
    January 20, 2021 1:39 pm
    We can use hierarchical custom settings so we can control this per user.
    Jon W
    January 20, 2021 3:23 pm
    This is a good approach. We do something similar but we have the automations exclude a data profile.
    March 12, 2021 4:14 am
    This is great, but since you can't save a process builder without an action, it would be nice to see complete setup. I have no idea what to do next. I mean, I guess I could send an email to myself reminding me to turn the automation back on?
    Christine Marshall
    March 12, 2021 11:42 am
    Hi Sam, I'm not 100% sure what you're asking here? Perhaps you could rephrase the question so we can see if we can help? Thanks, Christine
    March 13, 2021 7:53 am
    I'd like to see a Process Builder implementation example.
    Christine Marshall
    March 15, 2021 9:18 am
    Thanks for the feedback Sam. We'll take that onboard and see if we can update the post in future to include Process Builder.
    Saicharan Reddy Kasireddy
    September 26, 2021 12:18 pm
    Hello Sam, You can invoke a dummy Apex class with an invocable method that has nothing. public class ProcessBuilderDoNothing { @InvocableMethod public static void DoNothing() {} } Thanks.
    August 10, 2022 3:39 am
    Nice article, exactly what I would do for a freshly new org. Do you have any idea on how to implement something like this on a legacy system without updating all of the existing automations?
    November 10, 2022 11:39 pm
    I am also in a same need. Abimanyu - Did you find an easy solution for it?
    December 31, 2022 9:24 am
    How could this custom label and a validation rule or a flow can help to turn off all Org Validations and flows , could you please enlighten me . Does this mean all the validation rules and flow needs to be modified by adding this condition in order to turn them off per object
    December 31, 2022 5:56 pm
    This is a great approach to disable automations/validations by profile but you can’t always coordinate that in an org. We use a similar approach with a custom field added to the User Detail which allows us to turn it off per user.
    January 02, 2023 3:18 pm
    Hey Bart, thanks for the article and the idea. A single click solution sounds great! I do have one thought that I would like to share with you: With the goal to be able to import data without interrupting daily business by switching off automation, we implemented a solution with custom permissions like "Skip Validation Rules" that are handled similar to the way you mentioned on your article. Doing so allows us to empower the data import user with permissions to bypass any automation without shutting down anything else.
    Sailaja K
    May 06, 2023 4:04 pm
    I used this idea in my new org and it works great! I have setup 3 flags considering bypass settings for Flows, validation rules and Triggers.
    May 16, 2023 2:36 pm
    Would a custom permission set assigned to the system admin user work as well? or is it better to assign a flow exclusive for the system administrator(s).? If so how and what would that look like?

Leave a Reply