You need to sign in to do that
Don't have an account?
MarkL.ax269
Force.com IDE deactivating triggers in production
Maybe I'm missing the obvious here, but I can't figure out how to deactivate a trigger in a production environment. I created a simple trigger in the sandbox, tested and deployed it to production. Everything works fine and the trigger works as expected in production. However now I would like to deactivate and/or undeploy it from production. In the sandbox I can edit the trigger and uncheck the IsActive field, but I can't edit the trigger in production (I am the system administrator) because there is no Edit link.
I tried deactivating in the sandbox and then redeploying to production, but that didn't work either. Do I need to write a deployment script, access the metadata, use Ant? Without the ability to roll back triggers from production, I can't use Apex. What am I missing? I searched all the documentation and this forum and didn't find anything other than references to the UI checkbox, which doesn't exist in production.
Mark
Message Edited by MarkL on 02-21-2008 09:48 AM
I tried deactivating in the sandbox and then redeploying to production, but that didn't work either. Do I need to write a deployment script, access the metadata, use Ant? Without the ability to roll back triggers from production, I can't use Apex. What am I missing? I searched all the documentation and this forum and didn't find anything other than references to the UI checkbox, which doesn't exist in production.
Mark
Message Edited by MarkL on 02-21-2008 09:48 AM
All Answers
What I was told is that when Spring 08 goes in, we will be able to edit the IsActive checkbox.
Fortunately for us, we can wait until Friday night. So, we're just sitting here with a trigger in force - but no data load. Not really bad.
What we learned is to reserve one of our Sandboxes as the "play-pen" for next upgrade preview. In that manner, we'll have the sandbox with all our data mirrored on the same release level as Production.
When I spoke with SF tech support this morning, they told me that there is an "is active" flag that you set in the trigger itself, but I have not found any documentation regarding this.
Does anyone know where to look?
Mark
So how do you disable a trigger in production?
Mark
Here is my code for the XML,
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<active>true</active>
<apiVersion>11.1</apiVersion>
</ApexTrigger>
This is autogenerated by Eclipse as part of the web service for the trigger.
I am having the same problem though, the trigger tests and deploys but when I set to active it will not change on prod?
Any ideas?
Since we really want the trigger we finally got into production, I didn't try this - but if you delete the trigger from your project (obviously, you'd save a copy somewhere), and then choose the Deploy to Server option from when you highlight the project, right click and choose Force.com - the system will recognize it's on the server, but no longer in the Eclipse world. So, instead of the Green Add or Yellow Overwrite, you should see the Red Delete highlighting when you want to check which items you're going to work with on this particular deployment.
Good luck, let us know.
Ron Hess wrote:
i believe you must deploy a trigger which is marked inactive, or one which contains an empty body.
I just tried this. I updated the active tag in the sandbox to false and saved it to the server - I should mention I'm using an Apex sandbox. This worked perfectly, the trigger was deactivated in the sandbox. Then I tried to deploy the trigger to production and got several issues.
So I just added a comment to the trigger to force a change. This caused it to show in the deployment plan as an Overwrite. Ok so far. Then I tried to validate the plan and got a test coverage error of 0%. I can only assume this is because I'm deactivating the trigger since coverage was 100% when it was active.
Finally I tried to deploy it anyway, ignoring the test coverage error. This of course resulted in an error and my trigger is still active in production. Some comments:
I hope this is constructive, I really like what you have done so far. This has been the real missing link in development on the platform and it's a HUGE step forward. Keep up the good work!
Mark
ps - I also updated the subject of this thread since it seems to focus on the IDE
Message Edited by MarkL on 02-21-2008 09:49 AM
Yesterday, I addressed the issue in our tcon w/ our agent. He suggested we comment out the code.
I then asked how to get 75% code coverage. He wasn't sure.
This will work (99% guaranteed ... I think).
Choose 2 fields you're not using (if you're using all the Fields, on all the objects, you have my profound sympathy ... you might even want to change the trigger to work on a little used (or custom) object. Test to see if field1 has changed. If so, add an object to the list of objects to update, and set field2 to some value (e.g. "changed"). Then, write your testMethod to create an object, change the field1 and assert that field2 will be what you set it to.
"Not everything worth doing is worth doing right." - Tracy Kidder, Soul of a New Machine.
I got
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<active>false</active>
<apiVersion>12.0</apiVersion>
</ApexTrigger>
try this:
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>14.0</apiVersion>
<status>InActive</status>
</ApexTrigger>
I'm having a problem going the other way. I create the trigger in the IDE, no problems. I create a class to test it, %100 code coverage.
I can deploy to production, no problems, but making a change to the status in the xml does nothing, and there's no way to change the value in production.
Did you try the remedies proposed in previous posts? [Delete from project, then deploy; commenting out all code - or deleting it all & then doing some 'no op' code; etc.]
Have you asked SF? One of the good things (or bad things - depending upon point of view), is that there are such frequent (usually totally painless) updates.
I triend deleting it from project, then deploying with all code commented, I tried making some trivial code changes
but what I always wind up getting is changes to the xml are only saved locally, and do not deploy to production.
On the last run through, my test class vanished into the ether, so now I'm mucking with that again to get my test coverage.
2 things.
First, there's got to be a way to delete or make it go Inactive. Become the squeaky wheel until SF shows you how to make it happen (or does it for you).
Second, on "my test class vanished" - do you have in instance where SF either lost or rendered unusable your .cls? or did you do it locally & did a save to server - without backup on something like Subversion (not that I know anyone whose ever done that, or done it myself;)
After struggling with deactivating a trigger, I finally figured it out with the help of Premier support. However, it is a can of worms because upon deployment of the change from Active to Inactive, your test case will still run and your code coverage will probably fail because the trigger is not fired. The ridiculous solution is to modify the test case to invoke the class called by the trigger, and then when re-activating the trigger, take that line out of the test case. This probably only happens if your trigger invokes external classes (as mine did), but in my opinion this still makes absolutely no sense. However, that is what I was told I needed to do.
The better solution is to, in the metadata XML file for your trigger, set the Status to "Delete" instead of "Inactive". Run deployment and the trigger will be removed. When you are ready to re-activate the trigger, deploy it again with the status set to "Active". In the long run this will save a lot of time. No mucking with your test cases. It is very easy.
In either case -- whether you choose to set Status to Delete or Inactive, ther is one pesky issue here that I ran into and others might be encountering...I noticed that if you set the status in the metadata file using the pick-list and then, in Eclipse, click the "Force.com->Save to Server" menu selection for that metadata file, it changes it back to what it was before you changed it! In other words, if Status was previously set to "Active" and you changed it to "Inactive" and then clicked "Force.com->Save to Server", that action changes it back to "Active". So just make the change using the Status drop-down and do not save the change. It will be saved automatically.
Delete is not valid status Eclipse tells me.
Seriously, I just want to shut this **bleep** trigger off for a while. Delete, inactivate, this thread is 3 pages of people stugglring with this. Why isn't this simpler?
Hi All,
I do not know why you people are making this very complex. If you want to deactivate a trigger in production , change the status of the trigger in sandbox as mentioned below and deploy it to production.
Cool..
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>16.0</apiVersion>
<status>Inactive</status>
</ApexTrigger>
to again activate the trigger , just change the status to Active and deploy it to production.
If you still have any queries fell free to drop a mail to me at manoj.kumar@emdiesels.com
Cheers..
Enjoy Working..
Manoj
The way that I have found that works best for me to 'deactivate' a trigger is to simply create a custom setting Boolean var.. something like disableXXXTrigger [true/false] and then create a util method that looks at this setting and just wrap the trigger logic with it.. ie...
That way your not relient on meta data or others things that SFDC may change and you can change this in the UI without any dev tools.
(Utils contains code to retrieve the custom setting)
That's what we have started doing as well - via boolean vars in Custom Settings. This way you can enable/disable triggers in Production immediately, without having to redeploy anything.
I need to do this as well. Can you please include example of what you defined in the custom settings? Based on your code, is Utils the name of the custom setting? The if statement taking the current user logon, what is that comparing against? Did you create a column in the custom setting to also stamp the user you want to allow to bypass this trigger?
There are a number of ways to stop a trigger to run. I've consolidated the list. Read here
https://sfdcfanboy.com/2017/11/23/a-tip-a-day-23-5-ways-to-stop-trigger-in-production/ (https://sfdcfanboy.com/2017/11/23/a-tip-a-day-23-5-ways-to-stop-trigger-in-production/)