function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Paula Jarvis 4Paula Jarvis 4 

Contact Validation Rule misfiring

I have a VR that requires all Users except for Sys Admin and Data Integrity Officer to enter an EMail Address for a particular Contact Record Type. This VR is not recognizing that Users actually entered an email address. It still blocks the User from saving ther record even though the email address is entered. Here is my VR. Feedback would be appreciated. Thank youDeveloper Community!
AND( 
$Profile.Name <> 'Custom Data Integrity Officer', 
$Profile.Name <> 'System Administrator', 
AND( 
OR( 
ISNEW(), 
ISBLANK(Email), 
AND(RecordTypeId = "012500000009VLe"))))
Best Answer chosen by Paula Jarvis 4
venkat-Dvenkat-D
Try
AND( 
$Profile.Name <> 'Custom Data Integrity Officer', 
$Profile.Name <> 'System Administrator', 
ISNEW(), 
ISBLANK(Email), 
RecordTypeId = "012500000009VLe")

All Answers

venkat-Dvenkat-D
Try
AND( 
$Profile.Name <> 'Custom Data Integrity Officer', 
$Profile.Name <> 'System Administrator', 
ISNEW(), 
ISBLANK(Email), 
RecordTypeId = "012500000009VLe")
This was selected as the best answer
Paula Jarvis 4Paula Jarvis 4
Thanks venky! You rock!
Amit Chaudhary 8Amit Chaudhary 8
One minor change i want to suggest you. Please remove hard coding and update your validation like below

AND( 
$Profile.Name <> 'Custom Data Integrity Officer', 
$Profile.Name <> 'System Administrator', 
ISNEW(), 
ISBLANK(Email), 
RecordType.Name = "RecordTypeName")

Let us know if this will help you
 
Parker EdelmannParker Edelmann
@Amit Chaudhary 8, I've seen you request that the hard-coded ID should not be used in the past. What is the logic behind your recommendation?

Thanks,
Parker
Amit Chaudhary 8Amit Chaudhary 8
Hi Parker Edelmann  and Paula Jarvis 4,

As per salesforce best practice we should not use the hardcode id in salesforce code as well as in configuration.

ID in sandbox and production will not be same. Suppose if you are creating this validation rule inside sandbox and deploying same in production in that case this fromula/ validation rule may not work in case if ID of role will not match.
 
venkat-Dvenkat-D
The idea is when you create a new record type in production its id will be different from Id in QA. Then to avoid changing id in Production rule , you can use name .