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
arasuarasu 

How to disable Apex triggers in production? need to carry out mass updates using Apex Data Loader

Hi,
 
Yesterday I had deployed aan apex trigger from sandbox to production env. The trigger is an "before insert, before update" to check for duplicate account names. The trigger works fine in prodiuction for preventing duplicate Account names.
 
But today when I tried to mass update Accounts for some other field using Apex Data Loader, I get the following error:
 

Apex script unhandled trigger exception by user/organization: 00530000000nHi3/00D300000006QZD

Trg_Account_Name_Dedup: execution of BeforeUpdate

caused by: System.Exception: Too many SOQL queries: 21

Trigger.Trg_Account_Name_Dedup: line 1, column 143

Can anyone please advise on how to disable triggers in production env so that I can carry out other mass updates in Account using Apex Data loader tool.

Thanks and regards,
Ambili

lodoss118lodoss118
Same here how the hell do u disable them?
Ron HessRon Hess
in the app, you can edit the trigger and uncheck the is isactive check box
MarkL.ax269MarkL.ax269
Definitely can't uncheck anything in a Winter 08 org, the Edit link isn't there and no checkbox...even though the trigger itself is present and deployable. And at least one person has said it's not there in the Spring 08 org, but I have not seen that yet myself. I do have the checkbox in my sandbox, but that is spring 08.

Mark
arasuarasu

Hi Ron,

Thanks for your reposne...but we do not see any edit link/button nor do we have any edit permission on the Trigger in our production enterprise edition. Do we have to set up some options to edit the trigger?

Currently I am forced to delete the trigger via eclipse IDE to carry out Account mass updates and then again re-deploy the trigger back to prod. This is very cumbersome and dangerous as well.

Thanks and regards,

Ambili

lodoss118lodoss118
Hi right now what i did was just took out the main body i.e. delete the code and just redeploy the trigger to live?


example

Trigger updateEstDate on Case <after instert> {

  //delete alll your code and deploy, lol

}


Message Edited by lodoss118 on 02-14-2008 01:18 AM
Ron HessRon Hess
Yeah, that check box is not found in production, sorry to miss-lead you
spacemanspaceman
I think there are two ways around this. You could deactivate the trigger in sendbox (or Eclipse or whatever dev you are using) and then deploy. Or you could just set the batch size for the Apex Loader to a smaller value (The default is 200) so that you end up with fewer SOQL queries per batch.
Regards
MarkL.ax269MarkL.ax269
Ok I'm updated to Spring 08 in production and still no clear answer to this problem. No edit link or checkbox in the production org, so how do you disable a trigger?

Mark
Ron HessRon Hess
i believe you must deploy an updated trigger to your production org, one which has an empty body.
spacemanspaceman
Use the sendbox to mark the trigger as NOT active. Then deploy to production. You do not have an edit link in production but you'll see the "Is Active" field would not be checked. When you deploy you also change metadata - including the "Is Active"  field.
lodoss118lodoss118
yes but for my scenario i want to delete the trigger, i mean for the live system you should be allowed to at least delete the trigger i.e. show the **bleep** delete button dam you salesforce lol.
philbophilbo

You might also want to take a closer look at the problematic trigger - maybe you can re-structure the code so that it is more impervious to the size of the batch being processed.

Presumably your trigger is there for a reason?  Is there any concern for the integrity of your data if you start loading stuff into your prod. org without running it thru the trigger?

-philbo

MarkL.ax269MarkL.ax269
In my case it's a simple hellow world trigger that doesn't have a material affect on production, but there's no reason for it to remain active.  In fact, there has to be a way to deactivate a trigger in production or it severely limits the use.  I tried spaceman's method of deploying an inactive trigger and it still didn't work.  Deploying a trigger with no body is somewhat better, but it means I have to maintain the code separately and delete/recreate as needed.  Seems more of a broadaxe than a scalpel.  Hopefully the new IDE update will take care of the issues.

Mark
J&A-DevJ&A-Dev


MarkL wrote:
In my case it's a simple hellow world trigger that doesn't have a material affect on production, but there's no reason for it to remain active.  In fact, there has to be a way to deactivate a trigger in production or it severely limits the use.  I tried spaceman's method of deploying an inactive trigger and it still didn't work.  Deploying a trigger with no body is somewhat better, but it means I have to maintain the code separately and delete/recreate as needed.  Seems more of a broadaxe than a scalpel.  Hopefully the new IDE update will take care of the issues.

Mark


Same here. I was told that the IsActive checkbox would be available on prod with the new Spring '08 release, but this isn't the case.
Currently, the only way that I can "deactivate" a trigger on a production environment is by modifying my code in sandbox to comment out the class/trigger and then redeploying it into prod. I too hope the new IDE release addresses a way to aliviate this issue.
GlennAtAppirioGlennAtAppirio
Well, everyone could vote for my Idea Exchange posting, which I submitted on Jan. 2 -

http://ideas.salesforce.com/article/show/100376

Allow de-activation of Apex triggers in production

Currently, there is no way to de-activate an Apex trigger in production. Please allow this.

This may be required in a variety of situations:

* A new bug is found, causing an unhandled exception. You want users to be able to continue saving records that cause the exception, while you troubleshoot the bug in a dev/sandbox environment.

* You want to do a mass data load and specifically need to de-activate the trigger behavior for the mass load (this is a fairly common scenario in relational DB's).


lodoss118lodoss118
Using the ant tool you cand delete your triggers/classes, in the build the xml file put this in

<target name="delete">
        <sf:compileAndTest
                      username="${sf.username}"
                      password="${sf.password}"
                      server="${sf.serverurl}"
                      apiversion="10.0"
                      baseDir="mypkg">
           
            <deleteClass>Test_Assign_Case_Owner</deleteClass>
            <deleteClass>UpdateAccountOnCase</deleteClass>   
            <deleteClass>Update_Current_Owner</deleteClass>               
            <deleteTrigger>updateEstDate</deleteTrigger>
            <deleteTrigger>updateCaseOwner</deleteTrigger>
            <deleteTrigger>updateAccount</deleteTrigger>
        </sf:compileAndTest>
    </target>

then in comandline put ant delete
MarkL.ax269MarkL.ax269
Thanks Glen, I just promoted it.  This is a very big deal for us.  And for those who recommend deleting, that is just not a viable solution for us.  If I have a systems analyst who needs to migrate in a large volume of data, they need the ability to disable triggers.  And that person will probably not have API skills and will certainly not be familiar with Ant.
jtkjtk
I'm new to Apex development and have ran into the same problems with undeploying as you all have. I tried what lodoss118 suggested by using Ant and the <deleteTrigger> and <deleteClass> elements but this didn't work. BUT, I was able to deactivate a trigger by:
  1. Edit the trigger meta.xml file and set the active attribute to false. I tried this through Eclipse but it didn't allow me to update the values. So I went  out to the shell and edited with a text editor.
  2. Back in Eclipse, open the trigger meta.xml file. It told me it had been changed in the file system and asked if I wanted to bring in the version on disk. I said yes.
  3. Now edit the trigger file - you just need to make a simple change so you can write it back out. This will also write it to your organization. This caused my trigger to not be active.
Hope this works for others. Hopefully Salesforce will come up with a way to deactivate a trigger from the Salesforce GUI.

  jeff

franklin_atxfranklin_atx

It's taken a long time to find some answer to this thread but this is what I've done and it work and you can keep the code in the event you need to modify or use it later.

 

1. Log into you sandbox and edit your trigger and remove the check back for "IS ACTIVE".

2. Using Salesforce IDE/Eclispe, log into your sandbox instance

3. Go to your triggers that you marked as Inactive and deploy them to Production.

 

This is the only way I've found where you can mark the trigger as INACTIVE without deleting them. It tooks 5 minutes to execute and days to find this resolution.

 

David

DrawloopSupportDrawloopSupport

Does anyone know if this can be done for managed triggers? Salesforce just pushed out an update to the LMA and the trigger is causing problems for us. Thought I'd ask while I await my sandbox refresh.

 

Thanks!

TryCodingTryCoding

hi

i am also having almost the same problem

i have a managed package, an object and before insert trigger in that package

now i want to create the object instance from apex code in my org but i can not fulfil trigger criteria.

How can i bypaas that trigger and insert an insatance of that object from my apex code

 

please suggest some solution or some cheat

 

regards

TryCoding

salesforcecrapsalesforcecrap

In my scenario, I have triggers that create @future jobs. Right now I cannot deploy to production via Eclipse; I receive an error message stating that deploying to production is not possible while @future jobs are in the queue.

 

How the hell am I supposed to use the weak approach of commenting out my trigger code and redeploying, when I can't deploy in the first place? This is a critical flaw in the SF management interface. I need to be able to disable triggers via the SF web interface.

DrawloopSupportDrawloopSupport

You should be able to do this using the migration tool. You will need to retrieve the class, make your changes, and deploy it back to Salesforce.

 

http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf

Nathan PattersonNathan Patterson
I know this has been around a while, but another solution is to implement a flag in Custom Settings and then update reference that flag in your triggers/apex code.  
So all you would do is create a new Hierarchical custom setting called something like TriggerControl.  Then for each trigger create a flag and perhaps a flag to disable all triggers.

Then in each of your triggers retrieve the flags and put an "if" statement around the trigger code.
Matt FosterMatt Foster
When we deploy triggers we always include a object "(customer name) triggers" with a active checkbox. So you can easily deactive when necessary. User-added image
Sourabh ShrivastavaSourabh Shrivastava
Sourabh Shrivastava
I am a newbie in saleforce. I found a very simple solution for this problem.
 
To make trigger in inactive or active on production 

1.Download the trigger from production using the Eclipse IDE.
2.After that double click the  YOURTRIGGERNAME.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>23.0</apiVersion>
    <status>Active</status>
</ApexTrigger>

  User-added image 

Just change the Status active to inactive.

3.Deploy the trigger to server.

Hope this will solve prob.
 
Jancy MaryJancy Mary
@Sourabh,

The steps which you specified are absolutely correct, I could see the same steps posted on salesforce's other discussion page, can you please help me to know whether the same way is possible to Deactivate or Activate a Trigger which is from an Installed Package. 

Extra Details for reference: To get the Eclipse and Force.com IDE people can use these links:

Instructions to install Force.com IDE on the Eclipse JUNO.
https://developer.salesforce.com/page/Force.com_IDE_Installation

Link which tells how to take the Components from your Salesforce org to Force.com on Eclipse (How To Get All Salesforce Components In Force.com IDE).
https://www.minddigital.com/how-to-get-all-salesforce-components-in-force-com-ide/


Cheers,
Jancy Mary

 
Balakrishna N 25Balakrishna N 25
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.
sfdcFanBoysfdcFanBoy
There are a number of ways to stop a trigger to run.  I've consolidated the list with tips for each approach.  Read here:

https://sfdcfanboy.com/2017/11/23/a-tip-a-day-23-5-ways-to-stop-trigger-in-production/