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 for Country, Record Type and Profile

I need to write a Mailing Address validation rule that only allows two profiles to edit/create a particular record type as well as notifying the User to spell out the Country. I have resorted to two validation rules as follows however I was hoping I could combine them. Any thoughts experts?

AND( 
!OR( 
$Profile.Name = "Custom Data Integrity Officer", 
$Profile.Name = "System Administrator"), 
OR( 
MailingCountry = 'U.S.', 
MailingCountry = 'US', 
MailingCountry = 'USA', 
MailingCountry = 'U.S.A.', 
MailingCountry = 'United States of America' 
))


Second VR:
Contact Validation Rule ~ Salesforce - Enterprise EditionAND(
!OR(
$Profile.Name = "Custom Data Integrity Officer",
$Profile.Name = "System Administrator"),
OR(
ISBLANK( MailingStreet ),
ISBLANK( MailingCity ),
ISBLANK( MailingState ),
ISBLANK( MailingPostalCode ),
ISBLANK( MailingCountry ),
$RecordType.Name = "Customer Contact"
))
 
Best Answer chosen by Paula Jarvis 4
Paula Jarvis 4Paula Jarvis 4
This is an edited version of a working VR. Thanks to both of you for providing answers.

Contact Validation Rule ~ Salesforce - Enterprise EditionAND(
!OR(
$Profile.Name = "Custom Data Integrity Officer",
$Profile.Name = "System Administrator"),
OR(
ISBLANK( MailingStreet ),
ISBLANK( MailingCity ),
ISBLANK( MailingState ),
ISBLANK( MailingPostalCode ),
ISBLANK( MailingCountry ),
AND(
OR(
MailingCountry = 'U.S.',
MailingCountry = 'US',
MailingCountry = 'USA',
MailingCountry = 'U.S.A.',
MailingCountry = 'United States of America'
),
$RecordType.Name = "Customer Contact"
)))

All Answers

Mahesh DMahesh D
Hi Paula,

You can this:
 
AND( 
!OR( 
$Profile.Name = "Custom Data Integrity Officer", 
$Profile.Name = "System Administrator"), 
OR( 
MailingCountry = 'U.S.', 
MailingCountry = 'US', 
MailingCountry = 'USA', 
MailingCountry = 'U.S.A.', 
MailingCountry = 'United States of America' 
),
OR(
ISBLANK( MailingStreet ),
ISBLANK( MailingCity ),
ISBLANK( MailingState ),
ISBLANK( MailingPostalCode ),
ISBLANK( MailingCountry ),
$RecordType.Name = "Customer Contact"
)
)

Please do let me know if it helps you.

Regards,
Mahesh
Naval Sharma4Naval Sharma4
Hi Paula,

Here is the combined VR.
AND(
!OR(
$Profile.Name = "Custom Data Integrity Officer",
$Profile.Name = "System Administrator"),
OR(
ISBLANK( MailingStreet ),
ISBLANK( MailingCity ),
ISBLANK( MailingState ),
ISBLANK( MailingPostalCode ),
ISBLANK( MailingCountry ),
!OR( 
MailingCountry = 'U.S.', 
MailingCountry = 'US', 
MailingCountry = 'USA', 
MailingCountry = 'U.S.A.', 
MailingCountry = 'United States of America' 
),
$RecordType.Name = "Customer Contact"
))

 
Paula Jarvis 4Paula Jarvis 4
@Mahesh D - I tried the VR format you provided however Users are able to leave the address fields blank but the Country Field is defiitely working properly. For example, I can leave the street field empty and the VR does not trigger. Any thoughts?
Paula Jarvis 4Paula Jarvis 4
@Naval Sharma 4 - I tried your VR as well and I can't get out of the VR even though all address fields are populated and the Country = United States.
Paula Jarvis 4Paula Jarvis 4
This is an edited version of a working VR. Thanks to both of you for providing answers.

Contact Validation Rule ~ Salesforce - Enterprise EditionAND(
!OR(
$Profile.Name = "Custom Data Integrity Officer",
$Profile.Name = "System Administrator"),
OR(
ISBLANK( MailingStreet ),
ISBLANK( MailingCity ),
ISBLANK( MailingState ),
ISBLANK( MailingPostalCode ),
ISBLANK( MailingCountry ),
AND(
OR(
MailingCountry = 'U.S.',
MailingCountry = 'US',
MailingCountry = 'USA',
MailingCountry = 'U.S.A.',
MailingCountry = 'United States of America'
),
$RecordType.Name = "Customer Contact"
)))
This was selected as the best answer