Skip to content

Instantly share code, notes, and snippets.

@practicalli-johnny
Last active August 29, 2015 14:14
Show Gist options
  • Save practicalli-johnny/784aabd6b76e11b4dbac to your computer and use it in GitHub Desktop.
Save practicalli-johnny/784aabd6b76e11b4dbac to your computer and use it in GitHub Desktop.
Trigger to restrict contact by last name
trigger RestrictContactLastName on Contact (before insert, before update) {
// Prevent updating or inserting a Last Name to the value of 'INVALIDNAME' in a Contact record
For (Contact contact : Trigger.New) {
if(contact.LastName == 'INVALIDNAME') {
contact.AddError('The Last Name "'+contact.LastName+'" is not allowed for Contact records');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment