function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AntjeAntje 

Disable Trigger

Hi,
I am new to the devolper side. So please be patient with me :)
I currently have two triggeres in production that do what they were designed to do. However, I will need to make some modifications to them, as they are screwing other things up. I know that I will have to use my sandbox for this but I can't seem to figure out how to deactive/disable them without deleting the triggers. I appreciate your help. Thanks
Best Answer chosen by Antje
Amit Chaudhary 8Amit Chaudhary 8
If you want to deploy inactive trigger in prod then you need to change code coverage first.

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Hi Antje,

Please check below post. I hope that will help u:-
How do I disable a Trigger in a production environment?
https://help.salesforce.com/apex/HTViewSolution?id=000005417&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000005417&language=en_US)

Important: You must consider the consequences of disabling a trigger in the production environment during work hours. It is highly recommended to perform this work outside normal business hours and to disable access to the application to non administrators during the maintenance period.

Follow these steps:
Disable the trigger on the sandbox environment
Create a new project in Eclipse using the Sandbox and including the trigger (or refresh your existing Eclipse project)
Alternative: edit the triggername.trigger-meta.xml in an existing project and change the status node to false: <status>Inactive</status>
Save the change locally
Deploy the trigger to productionComplete the data loadIf 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

Disable or delete an Apex Class or Trigger from a Production Organization
https://help.salesforce.com/apex/HTViewSolution?id=000006188
1. Force.com IDE should be installed.
2. Connect to the Sandbox Instance using the IDE and find the class or trigger that you want to delete.
3. Open the matching .xml file, and change the Status XML tag from Active to Deleted. 
4. Or to disable the trigger change it to Inactive.
Note: Apex class Status can only be changed to "Active" or "Deleted," not "Inactive".
5. Save the file.
6. Select the two files (Code and XML) using "Ctrl-click," and then right-click on one of them.
7. Select Force.com | Deploy to server.
8. Provide your credentials for the Production org and follow the steps.

Please let us know if this will help u

Thanks
Amit Chaudhary
 
AntjeAntje
Hi there, I am not familiar with Eclipse….what I did so far is, I selected the “Inactive” checkbox for my Triggers in my sandbox, but I don’t know what to do with the classes. I have tried to delete them in my sandbox. But after that I obviously can’t select them anymore to add them to the outbound change set. I read through the articles that you provided. Yet, I am still not sure what to do with the Apex classes. Thank you for your help, Antje
Amit Chaudhary 8Amit Chaudhary 8
Do one thing follow below step:-
Step 1:- logged in sandbox
Step 2:- Open trigger and click on edit 
Step 3:- Then click uncheck active check box. Your trigger will deactivate .
User-added image
Step 4:- Then deploy trigger in production

Please let us know if this will help u

Thanks
Amit Chaudhary
AntjeAntje
Hi Amit,

I did that. When I deployed into production, I got an error message in my delpoyment status "
Code Coverage Failure
Your code coverage is 0%. You need at least 75% coverage to complete this deployment."

My code in my sandbox and production was at 100%. Once I unchecked the box that you are referring to, and I depoly, I got the error message above. 

Thank You,
Antje
AntjeAntje
My code coverage is 100%. As soon as I change my triggers to "inactive", code cover is 0%. Therefore, I am unable to delpoy it into production. 
Amit Chaudhary 8Amit Chaudhary 8
If you want to deploy inactive trigger in prod then you need to change code coverage first.
This was selected as the best answer
AntjeAntje
I guess that is what I don't understand. My code coverage is at 100% as long as I don't deactive my triggers...