Skip to content

Instantly share code, notes, and snippets.

@lfreeland
Last active February 22, 2019 17:55
Show Gist options
  • Save lfreeland/18fd5691ad3ba61f1001cc4815c0613f to your computer and use it in GitHub Desktop.
Save lfreeland/18fd5691ad3ba61f1001cc4815c0613f to your computer and use it in GitHub Desktop.
Simple Trigger Framework Insert Validation Handler Example
public with sharing class AccountTriggerHandler extends TriggerHandlerBase {
protected override void beforeInsert(List<Sobject> newRecords) {
List<Account> newAccounts = (List<Account>) newRecords;
for (Account newAcct : Trigger.new) {
if (newAcct.Name == ‘bad’)
newAcct.addError(‘Bad Name’);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment