Activity Forums Salesforce® Discussions Is it possible to Deactivate a trigger from Apex in Salesforce? If yes, then how?


    March 23, 2018 at 8:29 am

    Hi Ankit,

    You could do this from IDE.

    Find the trigger.meta.xml of respective trigger and make this change and deploy.

    <?xml version="1.0" encoding="UTF-8"?>
    <ApexTrigger xmlns="">

    Hope this helps you.

  • Neha

    March 23, 2018 at 8:31 am

    Hi Ankit,

    You can Inactive the trigger using following steps:

    • Login to the sandbox
    • Go to the Trigger and Click on Edit and Uncheck the IsActive box (see the screenshot), and Click on Save
    • Create a Change Set and include the Trigger in the changeset and deploy the same into the Production.

    If you want to Inactive trigger using Apex code then you can add your own switch (or switches):

    public class Triggers {
    public static Boolean areDisabled = false;

    trigger AccountTrigger on Account (after insert, after update) {
    if (Triggers.areDisabled) return;

  • Ankit

    March 23, 2018 at 8:35 am


    Thanks for the response,

    Is there any way to Inactive trigger in production without deployment or without edit trigger code?

  • Neha

    March 23, 2018 at 8:36 am

    You can try  Metadata API for ApexTrigger includes the status value that can be set to Active/Inactive/Deleted. You can call that from Apex.

  • Archit

    March 23, 2018 at 11:29 am

    Hello Ankit,

    The best possible way to choose below options to Inactive trigger in production.

    a) via IDE,
    Disable the trigger in sandbox environment [You should have a sandbox org which contains the same trigger]
    Create a new project in Eclipse using the Sandbox and including the trigger (or refresh your existing Eclipse project)
    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 Deploy the trigger to production
    Complete the data load
    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

    b) via Changesets,
    Disable the trigger in a Sandbox environment [You should have a Sandbox org which contains the same trigger]
    Create a new Outbound Change Set in the Sandbox
    Add the disabled trigger to the Change Set
    Upload the Change Set to your Production Org
    In Production, go to Inbound Change Sets and wait for the uploaded Change Set to be available
    Click Deploy to run the tests and apply the changes

    Hope It would be helpful !!

Log In to reply.

Popular Salesforce Blogs