Skip to content

Instantly share code, notes, and snippets.

@lfreeland
Last active February 22, 2019 17:01
Show Gist options
  • Save lfreeland/53a1055e7f59c791fec6cd52c45c9153 to your computer and use it in GitHub Desktop.
Save lfreeland/53a1055e7f59c791fec6cd52c45c9153 to your computer and use it in GitHub Desktop.
Insert Trigger Validation Example
trigger myAccountTrigger on Account (before delete, before insert) {
if (Trigger.isBefore) {
if (Trigger.isInsert) {
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