Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@noeticpenguin
Last active December 23, 2015 21:39
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 noeticpenguin/6698094 to your computer and use it in GitHub Desktop.
Save noeticpenguin/6698094 to your computer and use it in GitHub Desktop.
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