Last active
February 22, 2019 17:21
-
-
Save lfreeland/ce1b1a00dc78e5e61516323c0096d490 to your computer and use it in GitHub Desktop.
Update Trigger Validation Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger myAccountTrigger on Account (before delete, before update) { | |
if (Trigger.isBefore) { | |
if (Trigger.isUpdate) { | |
for (Account newAcct : Trigger.new) { | |
Account oldAcct = Trigger.oldMap.get(newAcct.Id); | |
if (oldAcct.Name != newAcct.Name && | |
newAcct.Name.containsIgnoreCase(‘Luke’) | |
newAcct.addError(‘Choose a better name’); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment