Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Public Class ContactTriggerLogic Extends TriggerHandler {
Map<Id,Account> newMap;
Public ContactTriggerLogic() {
this.newMap = (Map<Id, Account>) Trigger.newMap;
}
Public Contact addSnark(Contact c){
if(!c.lastName.contains(' is awesome!')){
c.lastName = c.lastName + ' is awesome!';
}
return c;
}
Public override void beforeInsert() {
for(Contact c : newMap.values()){
addSnark(c);
}
}
//if your trigger definition included before update you could include
Public override void beforeUpdate() {
for(Contact c : newMap.values()){
addSnark(c);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment