How to Disable Salesforce Triggers, Workflows and Validations When Working with Copado Data Deployments
When working with data deployments, you may want to disable any automated process or validation rules you have in place to guarantee a successful deployment.
In this article, we will show you how to deactivate a trigger, a validation rule, a workflow rule and a process builder flow.
Triggers
You can deactivate a trigger both manually or by means of an Apex trigger switcher.
To manually deactivate a trigger, follow the steps below:
- Navigate to Setup > Apex Triggers.
- Click on Edit next to the relevant trigger and uncheck the Is Active checkbox:
- Click on Save.
Alternatively, you can create an Apex trigger switcher as follows:
public class Triggers {
public static Boolean areDisabled = false;
}
trigger AccountTrigger on Account (after insert, after update) {
if (Triggers.areDisabled) return;
….
}
Validation Rules
You can deactivate a validation rule manually or setting up a switcher custom setting.
To manually disable a validation rule, follow the steps below:
- Navigate to Setup > Object Manager.
- Select the object that contains the validation rule you want to disable and click on Validation Rules.
- Select the relevant validation rule and click on Edit.
- Uncheck the Active checkbox and click on Save:
Alternatively, you can set up a switcher custom setting to deactivate a validation rule as follows:
Your_App_Settings__c s = Your_App_Settings__c.getInstance( UserInfo.getUserID() );
if( s.Disable_Validation_Rules__c ) return;
Workflow Rules
You can disable a workflow rule manually or by means of a piece of code.
To manually deactivate a workflow rule, follow the steps below:
- Navigate to Setup > Workflow Rules.
- Click on Deactivate next to the relevant workflow rule:
Process Builder Flow
To manually deactivate a process builder flow, follow the steps below:
- Go to Setup > Process Builder.
- Select an active process builder.
- Click on Deactivate on the top right corner: