Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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