Skip to content

Instantly share code, notes, and snippets.

@TheShubhamVsnv
Created July 7, 2021 11:42
Show Gist options
  • Save TheShubhamVsnv/48f6da3099cd84ed4fef099b9d45b8ff to your computer and use it in GitHub Desktop.
Save TheShubhamVsnv/48f6da3099cd84ed4fef099b9d45b8ff to your computer and use it in GitHub Desktop.
Throw Error when user tries to delete the contact without account
trigger ContactBeforeDelete on Contact (before delete) {
for( contact con : trigger.old)
{
if( con.accountId == null)
{
con.addError('Hey !!! you are not authrized to delete this contact');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment