+ Start a Discussion
JohanLiljegrenJohanLiljegren 

Deactivating triggers in Production? Sure you can!

In need of deactivating a trigger in Production? Haven't found a way to do it?
I don't know if people are aware of this, but I've seen numerous posts about it, I've suffered from it myself and even had support tell me it's not possible.

So I was a bit surprised when today, playing around in Eclipse, I successfully managed to deactivate and activate a trigger in Production!
What you need to do is to open the metadata file accompanying the trigger. So, if your trigger is Foo.trigger, you would have a Foo.trigger-meta.xml.
Open that one, change the value of the element <active> to "false" and save the file.
Once saved, doublecheck through the GUI and the checkbox for Active is no longer there!
Sweet!

Of course, to re-activate the trigger, just change the <active> element to "true" again.

Hope this helps someone.

//Johan
MarkL.ax269MarkL.ax269
Well I know this definitely did not work when I tried it since this is the way I handle triggers in the sandbox. But just to be sure I created a new project from my production instance (EE).  I verified the trigger is still active in the UI and then tried to update the xml tag to false, and it would not save to the server.  The error is "Test coverage of selected Apex Class and Trigger is 0%, at least 75% test coverage is required."  Well I have 100% coverage for this trigger because I ran the same test in the UI and got 100%, so something is definitely wrong with verifying test coverage in production...which might make sense since I'm trying to save to production instead of deploying - I don't think salesforce allows that.  And deploying an inactive trigger still doesn't work.

So I'm still left with commenting out the code and then deploying an active (if impotent) trigger to production.
paul-lmipaul-lmi
this only works if you're editing triggers in the live org, which is dangerous and unrecommended.  this is why eclipse has you develop in one org, and then deploy from that org to a target.
JohanLiljegrenJohanLiljegren
paul-lmi: I can't see why deactivating a trigger in Production would be more dangerous than deleting it from Production? Or am I not understanding your concern?
Of course, i would never develop a trigger in Production. I don't even think that's possible, is it?

//Johan
paul-lmipaul-lmi
it's possible to develop a trigger in production provided you can actually save it without error initially.

as far as my comment, i referred to editing triggers in production more generally, not just your workaround.

that is actually how i had to activate my trigger, so i know the pain there.
KajaKaja
Is this SFDC limitation?
 
I tried changing the xml  and right click on the package and select Save to Server from Eclipse. but the trigger status was not changed to Inactive! please help me

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

<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">

<active>false</active>

<apiVersion>10.0</apiVersion>

</ApexTrigger>

Dallas DaveDallas Dave
Change the value to "Inactive" instead of "false".  Also, you might need to use "Deploy To Server" instead of "Save to Server" depending on where you want the change to happen and how your project is set up.