I have a trigger live in production on Contact Object and I am trying to load a set of 500 records through data loader and I don't want that trigger to fire upon the contact records I am loading into my org through Data Loader.

How do I achieve. Is that possible, if yes, how? Can you help please.

Thanks in Advance.


You could either create a Custom Setting or a Custom Metadata Type that contains a checkbox called runTrigger (or something like that) . This is set to true , and you do a check at the top of the trigger code whether it should run or not. Mine is like this:

trigger ContactTrigger on Contact (after insert,before insert,after update, before update) {

// Custom setting called TriggerSetting__c  that has a boolean called ApexTrigger__c
// This is managed in the admin UI and set to True.
TriggerSetting__c mc = TriggerSetting__c.getOrgDefaults();

if(!mc.ApexTrigger__c) return;
rest of trigger code

This has though the huge caveat that you must remember after the dataload to switch it on again! If not then you may have a wonderful time updating those records according to business rules manually

  • 3
    This is why I use a hierarchy custom setting; I can turn off triggers per user or profile instead wholesale disabling. – sfdcfox Jan 24 at 23:28
  • Even then you must remember to switch it on and off again. I'm using hierarchy settings as well and I've forgotten to switch them on again more than once :) – akarnid Jan 25 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.