Loading

Disable a Salesforce Trigger in a Production Environment

Publish Date: Jan 16, 2025
Description

In general, triggers are not editable once deployed to a production org. However, in certain circumstances there might be a need to disable triggers in production.
 

Resolution

Note: Consider the consequences of disabling a trigger in the production environment during work hours. It is highly recommended to perform this during off-hours. Also, disable access to the application to non-administrators during the maintenance period.
 

Turn Off a Trigger in a Production Org

 

Via Salesforce CLI

  1. Create a package.xml file to retrieve the metadata of the trigger
  2. Authorize the org where you want to deactivate the trigger using the command sfdx force:auth:web:login
  3. Use the sfdx force:mdapi:retrieve command to retrieve metadata of the trigger using the package.xml file created earlier
  4. Once the metadata file is retrieved, unzip the file and in the triggername.trigger-meta.xml file change the status from Active to Inactive
  5. Now run the sfdx force:mdapi:deploy command to deploy the changes to the target org

 

Via Change Sets

  1. Disable the trigger in a sandbox environment.  You should have a sandbox org which contains the same trigger
  2. Create a new Outbound Change Set in the sandbox.
  3. Add the disabled trigger to the change set
  4. Upload the change set to your production org
  5. In production, go to the Inbound Change Sets and wait for the uploaded change set to be available
  6. Click Deploy to run the tests and apply the changes

       To see this information in video format, watch How to Disable a Trigger in a Production Org via Change Set.

 

Via Workbench

  1. Retrieve the trigger metadata using Workbench
  2. Unzip the retrieved metadata folder
  3. In the triggername.trigger-meta.xml file, change the status from Active to Inactive
  4. Now zip the folder back and deploy it using Workbench

 

Via Ant Migration Tool

  1.  Disable the trigger in the sandbox environment.  You should have a sandbox org which contains the same trigger.
  2. Create a new folder using the sandbox and include the trigger (or refresh yor existing folder)
    1. Alternative: edit the triggername.trigger-meta.xml in an existing project and change the status node to false: <status>Inactive</status>
    2. Save the change locally 
    3. Deploy the trigger to production
  3. Complete the data load
  4. If the change is not permanent or you want to enable the trigger again, then enable the trigger by making it active on the sandbox or project again and deploy it to production.

Note: The Salesforce Ant Migration Tool is retired in the Spring of 2024.  The tool continues to function for future API versions but is not updated with new functionality and is not supported.  To manage metadata changes, switch to Salesforce CLI for a modern, supported developer experience.  For more information, see Salesforce Ant Migration Tool End of Life.

Additional Resources

Refer to the article Deploy Change Sets from Sandbox to Production for more details on deploying change sets.

Knowledge Article Number

000385540

 
Loading
Salesforce Help | Article