Since you are new to Trigger, It's time to learn Trigger Factory. Please visit the below link for Trigger Best Practice and usage of Trigger Factory. https://debugonweb.com/2019/01/27/trigger-factory-salesforce/
For debugging trigger, http://www.infallibletechie.com/2015/10/how-to-cover-adderror-in-trigger-in.html
// hello everyone if you find it helpful then please mark as best ans trigger AllEventstrigger on Account (before insert,before update,before delete,after insert,after update,after delete) { if (trigger.isBefore){ if (trigger.isInsert){ AllEvents_Account('Before','Insert'); }else if (trigger.isupdate){ AllEvents_Account('Before','Update'); }else if (trigger.isdelete){ AllEvents_Account('Before','delete'); }else{ } } if (trigger.isAfter){ if (trigger.isInsert){ AllEvents_Account('After','Insert'); }else if (trigger.isupdate){ AllEvents_Account('After','Update'); }else if (trigger.isdelete){ AllEvents_Account('After','delete'); }else{ } }
All these are trigger context variables.These variables are contained in the System.Trigger class.
Please refer below links which might help you in this.
https://developer.salesforce.com/forums/?id=9060G0000005ixrQAA
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm
Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.
Thanks and Regards
Go through this document https://www.iterativelogic.com/salesforce-apex-trigger-best-practices/ and post if u need any further assistance.
Thanks For Your Help
Thanks For Your Help
Since you are new to Trigger, It's time to learn Trigger Factory.
Please visit the below link for Trigger Best Practice and usage of Trigger Factory.
https://debugonweb.com/2019/01/27/trigger-factory-salesforce/
For debugging trigger,
http://www.infallibletechie.com/2015/10/how-to-cover-adderror-in-trigger-in.html
trigger AllEventstrigger on Account (before insert,before update,before delete,after insert,after update,after delete) {
if (trigger.isBefore){
if (trigger.isInsert){
AllEvents_Account('Before','Insert');
}else if (trigger.isupdate){
AllEvents_Account('Before','Update');
}else if (trigger.isdelete){
AllEvents_Account('Before','delete');
}else{
}
}
if (trigger.isAfter){
if (trigger.isInsert){
AllEvents_Account('After','Insert');
}else if (trigger.isupdate){
AllEvents_Account('After','Update');
}else if (trigger.isdelete){
AllEvents_Account('After','delete');
}else{
}
}
public static void AllEvents_Account(string s1,string s2){
system.debug(s1+'---'+s2+'--trigger.new--'+ trigger.new);
system.debug(s1+'---'+s2+'--trigger.old--'+ trigger.old);
system.debug(s1+'---'+s2+'--trigger.newmap--'+ trigger.newmap);
system.debug(s1+'---'+s2+'--trigger.oldmap--'+ trigger.oldmap);
}
}