+ Start a Discussion
sudhirn@merunetworks.comsudhirn@merunetworks.com 

Disable trigger during data loader mass update

Hi, 

  Do we have any option to disable trigger during data loader mass update? Please suggest me if we have any options to disable. 

Thanks
Sudhir
Sumit Kumar Singh 9Sumit Kumar Singh 9
I don't think that you can deactivate the trigger directly in the production.

1) You will have to redeploy the trigger as inactive. Once the data loading is finished, again deploy it as active.
2) If you requirement is to disable the trigger frequently, better to have a custom setting, based on the value of custom setting value you can toogle it.

Thanks,
Sumit kumar Singh
Amit Chaudhary 8Amit Chaudhary 8
Hi Sudir,

No, You cannot deactivate the trigger directly in production.

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=000006188

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 production
  • Complete the data load
  • If 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

Please let us know if this will help you
sudhirn@merunetworks.comsudhirn@merunetworks.com
Thanks for your reply my requirement is not to disable the trigger I dont want trigger to fire during data loader mass update. Is there any alternativy approch to do this activity not to fire the trigger while mass update. 
GauravGargGauravGarg

Hi Sudhir,

Your requirement is clear and can be easily implement.
As far, I am understanding. The requirement is to fire trigger incase of record update, but do not want to update record in-case of mass update i.e. bulk update via data loader. 
1. Create a custom profile having all modify all access on all custom standard object. 
2. The profile should in salesforce licence. 
3. The profile can be named se "Integration"
4. Create a user 'Data Integration' and assign "Integration" profile.
5. Now login via user and reset its Security token.
Once this is setup.

1. You to need to add a check in trigger for profile or user. 
if(UserInfo.getLastName != 'Integration'){ 
  run trigger logic;
}
else{
 bypaas;
}

By following the above process, you will be able to migrate data bypassing the Trigger. 

Hope this will solve you problem.

Thanks,

Gaurav

RadnipRadnip
Ok just fallen across this thread and needs a bit of an update as things have moved on since this question was answered.

Don't use profiles or embed code to say if the user's lastname is this then bypass etc... You can use a hierarchical custom setting. This means you can have a setting called "Bypass Triggers" and then you can set all users/roles etc to false and be very proscribed which users/roles have triggers disabled. Then in your triggers just add a simple check to see if the BypassTriggers custom setting is true and to not run the logic. The reason you should use a hierarchical custom setting is you then have a lot more control over who gets that permission and also it's slightly hidden away so that Admins etc can't just choose (eg) the "integration profile" and not realise that then those users are using the system without any triggers firing which could cause a potential crazy mess. Alternatively, you could use custom metadata types... OR If you want Admin control/visibility have a Permission Set called "Disable All Triggers" and use that to assign to users so its REALLY obvious that adding this permission set will disable triggers rather than an "Integration" Profile which doesn't actually tell you what potential adverse reaction you will happen in the org.
Arnab Sarkar 8Arnab Sarkar 8
Hi,
It is not best approach to manually disbale-enable trigger. The best approach would be to use custom setting. Create a hierarchy custom setting, create a checkbox under that as a custom field. Default it should be true (checked). Before you load huge data in production set it as false (unchecked). In trigger logic please put all of your logic inside a if statment where we check if the checkbox is true

trigger abc on accout (after update) {
// Get the value of the checkboix field here
        if (dataload_runing) {
            //put all your code-logic here  
        }
}

Once data loading is over please reset the check-box as true so that trigger code will execute as-is

If my answer/solution looks fine, please mark it as best-answer