Skip to content

Instantly share code, notes, and snippets.

@arun12209
Last active Sep 7, 2022
Embed
What would you like to do?
TriggerSwitchCls
/***********************************************************************************
Class Name : TriggerSwitchCls
Description : This class can be used to stop the trigger execution for a transaction.
Created By : SFDC Lessons
Created Date : 09/06/2022
Modification Logs:
------------------------------------------------------------------------------------
Developer Date Descriptions
-------------------------------------------------------------------------------------
Arun Kumar 09/06/2022 Initial version
*************************************************************************************/
public class TriggerSwitchCls {
public static Boolean accountTriggerRunFlag = true;
public static Boolean opportunityTriggerRunFlag = true;
public static Boolean contactTriggerRunFlag = true;
public static Boolean opportunityLineItemTriggerRunFlag = true;
public static Boolean userTriggerRunFlag = true;
public static Boolean leadTriggerRunFlag = true;
//Account Trigger Switch Logic
public static Boolean canAccountTriggerExecute(){
return accountTriggerRunFlag;
}
public static void stopAccccountTrigger(){
accountTriggerRunFlag = false;
}
public static void allowAccountTrigger(){
accountTriggerRunFlag = true;
}
//Opportunity Trigger Switch Logic
public static Boolean canOpportunityTriggerExecute(){
return opportunityTriggerRunFlag;
}
public static void stopOpportunityTrigger(){
opportunityTriggerRunFlag = false;
}
public static void allowOpportunityTrigger(){
opportunityTriggerRunFlag = true;
}
//Contact Trigger Switch Logic
public static Boolean canContactTriggerExecute(){
return contactTriggerRunFlag;
}
public static void stopContactTrigger(){
contactTriggerRunFlag = false;
}
public static void allowContactTrigger(){
contactTriggerRunFlag = true;
}
//OpportunityLineItem Trigger Switch Logic
public static Boolean canOLITriggerExecute(){
return opportunityLineItemTriggerRunFlag;
}
public static void stopOLITrigger(){
opportunityLineItemTriggerRunFlag = false;
}
public static void allowOLITrigger(){
opportunityLineItemTriggerRunFlag = true;
}
//User Trigger Switch Logic
public static Boolean canUserTriggerExecute(){
return userTriggerRunFlag;
}
public static void stopUserTrigger(){
userTriggerRunFlag = false;
}
public static void allowUserTrigger(){
userTriggerRunFlag = true;
}
//Lead Trigger Switch Logic
public static Boolean canLeadTriggerExecute(){
return leadTriggerRunFlag;
}
public static void stopLeadTrigger(){
leadTriggerRunFlag = false;
}
public static void allowLeadTrigger(){
leadTriggerRunFlag = true;
}
//** Duplicate the above methods for other objects */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment