You need to sign in to do that
Don't have an account?

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
Mark
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
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
Regards
Mark
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
Mark
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).
<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
- 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.
- 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.
- 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
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
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!
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
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.
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
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.
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>
Just change the Status active to inactive.
3.Deploy the trigger to server.
Hope this will solve prob.
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
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.
https://sfdcfanboy.com/2017/11/23/a-tip-a-day-23-5-ways-to-stop-trigger-in-production/