Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created September 7, 2022 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/6655dd61b518e35c7e12f733ab012352 to your computer and use it in GitHub Desktop.
Save arun12209/6655dd61b518e35c7e12f733ab012352 to your computer and use it in GitHub Desktop.
StopTriggerHandler
/***********************************************************************************
Class Name : StopTriggerHandler
Description : This class can be used in the PB, flow to do the actions defined in the methods.
Created By : SFDC Lessons
Created Date : 09/06/2022
Modification Logs:
------------------------------------------------------------------------------------
Developer Date Descriptions
-------------------------------------------------------------------------------------
Arun Kumar 09/06/2022 Initial version
*************************************************************************************/
public class StopTriggerHandler {
/**
* @description stopTrigger method can be called from PB/FLOWs to stop the object trigger for a transaction.
* @param triggerNameToStop
*/
@InvocableMethod(label='Stop sObject Trigger' description='Stop the sObject trigger for this transaction')
Public static void stopTrigger(List<List<String>> triggerNameToStop){
for(String varTrggrName: triggerNameToStop[0]){
//switch statement checking trigger name and stoping the triggers
switch on varTrggrName {
when 'Account' {
TriggerSwitchCls.stopAccccountTrigger();
}
when 'Opportunity' {
TriggerSwitchCls.stopOpportunityTrigger();
}
when 'Contact' {
TriggerSwitchCls.stopContactTrigger();
}
when 'OpportunityLineItem' {
TriggerSwitchCls.stopOLITrigger();
}
when 'User' {
TriggerSwitchCls.stopUserTrigger();
}
when 'Lead' {
TriggerSwitchCls.stopLeadTrigger();
}
}//switch statement block ends here
}//for loop ends here
system.debug('Can Opportnity Trigger Execute ? : ' + TriggerSwitchCls.canAccountTriggerExecute());
}//mehod ends here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment