How to Disable Salesforce Triggers, Workflows and Validations When Working with Copado Data Deployments

Updated 4 months ago by Copado Solutions

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:

  1. Navigate to Setup > Apex Triggers.
  2. Click on Edit next to the relevant trigger and uncheck the Is Active checkbox:

  1. 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:

  1. Navigate to Setup > Object Manager.
  2. Select the object that contains the validation rule you want to disable and click on Validation Rules.
  3. Select the relevant validation rule and click on Edit.
  4. 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:

  1. Navigate to Setup > Workflow Rules.
  2. Click on Deactivate next to the relevant workflow rule:

Process Builder Flow

To manually deactivate a process builder flow, follow the steps below:

  1. Go to Setup > Process Builder.
  2. Select an active process builder.
  3. Click on Deactivate on the top right corner:


How did we do?