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
KJesseKJesse 

Active/Inactive Triggers With REST

Is it possible to deactivate a trigger with a REST call?

When I do a database mass import it doesn't make sense for my triggers to fire back to the database. So for the duration of the script, I would like to inactivate them, then reactivate.

Thanks,
Kevin
KaranrajKaranraj
In production instance you can't make an trigger inactive either manually or through API call. The one simplest one time solution will be use custom setting as switch to activate and deactive trigger code in your production instance.
trigger CaseAfterTrigger on Case(after insert, after update)
{
   TriggerActive__c isTriggerActive = TriggerActive__c.getValues('CaseTrigger');
   if(isTriggerActive.IsActive__c){
     //Your entire Trigger code logic
   }
}
TriggerActive__c - List Custom setting
IsActive__c - Checkbox custom field of custom settings

If the isActive__c field is set True or checked then your Trigger code logic will execute if the field is set to false or unchecked then your Trigger code logic won't execute.