Skip to content

Instantly share code, notes, and snippets.

@lfreeland
Created February 7, 2019 10:16
Show Gist options
  • Save lfreeland/ef3338b8292a15dad41ddd432c5a31c8 to your computer and use it in GitHub Desktop.
Save lfreeland/ef3338b8292a15dad41ddd432c5a31c8 to your computer and use it in GitHub Desktop.
Account Trigger Handler Example
public with sharing class AccountTriggerHandler extends TriggerHandlerBase {
protected override void beforeInsert(List<Sobject> newRecords) {
List<Account> newAccounts = (List<Account>) newRecords;
}
protected override void beforeUpdate(Map<Id, Sobject> oldRecordsMap, Map<Id, Sobject> newRecordsMap) {
Map<Id, Account> oldAccountsMap = (Map<Id, Account>) oldRecordsMap;
Map<Id, Account> newAccountsMap = (Map<Id, Account>) newRecordsMap;
// Do something with the Account records.
// Use private methods in this class to handle the work or
// delegate it to a service class.
}
// Use private methods to handle the heavy lifting
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment