Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created Sep 7, 2022
Embed
What would you like to do?
ContactTrigger
/**
* @description ContactTrigger.
* @Created By: Arun Kumar
* @Created Date : 26-06-2022
* @Last Modified Date : 26-06-2022
*/
trigger ContactTrigger on Contact (before insert,before update, before delete, after insert, after update, after delete,after undelete) {
// This "TriggerSwitchCls.canContactTriggerExecute()" will return TRUE or FALSE. By default it will return TRUE and
//if we bypass this in flow then it will return FALSE and trigger will be bypassed.
if(TriggerSwitchCls.canContactTriggerExecute()){
System.debug('Inside Contact Trigger');
TriggerHandler handler = new ContactTriggerHandler(Trigger.isExecuting, Trigger.size);
switch on Trigger.operationType {
when BEFORE_INSERT {
//call before insert handler method
handler.beforeInsert(Trigger.new);
}
when BEFORE_UPDATE {
//call before update handler method
handler.beforeUpdate(Trigger.new, Trigger.old, Trigger.newMap, Trigger.oldMap);
}
when BEFORE_DELETE{
//call before delete handler method
handler.beforeDelete(Trigger.old, Trigger.oldMap);
}
when AFTER_INSERT{
//call after insert handler method
handler.afterInsert(Trigger.new,Trigger.newMap);
}
when AFTER_UPDATE{
//call after update handler method
handler.afterUpdate(Trigger.new, Trigger.old, Trigger.newMap, Trigger.oldMap);
}
when AFTER_DELETE{
//call after delete handler method
handler.afterDelete(trigger.old, Trigger.oldMap);
}
when AFTER_UNDELETE{
//call after undelete handler method
handler.afterUndelete(trigger.new, Trigger.newMap);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment