You need to sign in to do that
Don't have an account?

Validate Contact object email if a custom field is checked
Hi All,
I have added a check box called "ValidateEmail" to Contact Object. When "ValidateEmail" is TRUE I want the before update and before insert trigger to check whether the EMAIL (field on Contact object) is empty or not.
If the "ValidateEmail" is TRUE and EMAIL is empty I dont want to add/update that record. Instead I want to show a validation error message. If the "ValidateEmail" is FALSE I dont want that validation.
How can I do this?
Any Help? Thanks in advance.
Try with the below Trigger
It sounds like you can achieve this with a simple validation rule on the Contact object so there is no need to write a trigger for this. A validation rule is best practice in this scenario as it is a 'Clicks not Code' approach which is easier for a system administrator to maintain.
Validation Rule
ValidateEmail__c == True && isBlank(Email)