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
TLeahyTLeahy 

HELP! I need to disable apex trigger already in production

I know there are some other posts about this, but I cannot make much sense of them I am new to apex and salesforce, learned a considerable amount in the time I've been working with it, but right now Im up against a wall, and its BAD

 

I, for whatever reason, could not make opportunities in my sandbox, could not figure out why, but wanted to try this trigger. So like a fool I put it to production. No nobody can create or edit anything [a Work order - custom object we use to project details]  We NEED this to work. My company is at a halt, I NEED to remove or disable this trigger asap.

 

I tried to mark it as inactive in sandbox, and push it to production, but it says "Average test coverage across all Apex Classes and Triggers is 72%, at least 75% test coverage is required." I have NOO idea what this means and no time to figure anything out. Needless to say - I am freaking out. PLEASE someone help.

Best Answer chosen by Admin (Salesforce Developers) 
suresh.csksuresh.csk

Hi.

 

To make trigger in inactive or active

1.Download the trigger from production using the IDE.

2.After that double click the  xxXXX.trigger-meta.xml.

the meta xml file looks like this

<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>24.0</apiVersion>
    <status>Active</status> ----> change this to Inactive
</ApexTrigger>

 

In the status xml tag you can set Inactive to de-activate the trigger.

3.Deploy the trigger to server.

 

thats it your tigger will not work in production.

 

cheers

suresh

 

 

All Answers

Anup JadhavAnup Jadhav

The quickest way to disable the trigger is to comment out the code inside the trigger. So if your trigger is like this:

 

trigger TestTrigger on dummy_object__c {

  integer test;
   // more trigger code

  .....

}

 

Just comment everything inside the trigger as using the block comment facility /*  */

trigger TestTrigger on dummy_object__c {
  /* start of block comment
  integer test;
   // more trigger code

  .....
  end of block comment */ 
}

 Your trigger basically does nothing. Now deploy this code to prod, and you should be okay atleast for the near future.

 

      - anup

 

TLeahyTLeahy

I've tried that, it won't let me save it. it says "Error: Compile Error: unexpected token: '<EOF>' at line 0 column -1"

TLeahyTLeahy

I downloaded and installed the Force.com IDE, it wouldnt let me delete the trigger. did not say why..or at least not very descriptly. It just said aborting delete. It wont let me block out the code either. It tells me "Expecting a left parantheses founD '{'  "

Whyy is this so difficult. I. Want. This. Trigger. Gone. 

suresh.csksuresh.csk

Hi.

 

To make trigger in inactive or active

1.Download the trigger from production using the IDE.

2.After that double click the  xxXXX.trigger-meta.xml.

the meta xml file looks like this

<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>24.0</apiVersion>
    <status>Active</status> ----> change this to Inactive
</ApexTrigger>

 

In the status xml tag you can set Inactive to de-activate the trigger.

3.Deploy the trigger to server.

 

thats it your tigger will not work in production.

 

cheers

suresh

 

 

This was selected as the best answer
TLeahyTLeahy

That is exactly what needed to happen, although I selected delete instead of inactive. trigger is gone, and the problem with it. Thanks!

suresh.csksuresh.csk

Happy to hear you need the same.

please mark my reply as answer so that others can be helped very easiy

 

cheers

suresh

irene1.388665708537493E12irene1.388665708537493E12
Hi, I'm trying desperately to deactivate a trigger and have tried all suggestions, but am getting nowhere. I have deactivated in the sandbox and uploaded to prod and tried to deploy, but I get an error "Failure Message: "System.QueryException: List has no rows for assignment to SObject", Failure Stack Trace: "Class.LeadConvertTest.leadconvert: line 25, column 1"".
There is no line 25 in the trigger!! There are only 22 lines.

I also tried editing the trigger in the sandbox and commenting out the code, but I get the same error when I upload and validate/deploy.

The trigger was created in 2010 - could there be a version problem?

I have Eclipse loaded but have no idea about how it connects to the IDE - sorry but have only used it once with much struggling and have forgotten. 

If I just download from my SF instance all it gives me is the trigger code, not the xml, so am needing some help please...
irene1.388665708537493E12irene1.388665708537493E12
Update - I have managed to load the Force.com IDE in Eclipse and have found the xml file. I set it to Inactive but when I try and deploy it gives me the same error. Help?
sfdcFanBoysfdcFanBoy
Yes, there are a number of ways to do it.  I have consolidated the list. 

5 Ways to Deactivate a Trigger in Production (https://sfdcfanboy.com/2017/11/23/a-tip-a-day-23-5-ways-to-stop-trigger-in-production/)
3 Ways to Delete an Apex class from Production (https://sfdcfanboy.com/2017/11/24/a-tip-a-day-24-3-ways-to-delete-an-apex-class-from-production/)