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
Ken S (OLD ACCOUNT)Ken S (OLD ACCOUNT) 

Validation rule to assume Country = United States if null, and force valid US 2-digit state and 5- or 9-digit zip code validation rules if Country = United States?

Can someone help me write a field validation rule(s) that says:

"if (MailingCountry = null or "United States"), AND any other address field (MailingStreet, MailingCity, MailingPostalCode, MailingStateCode = not blank), THEN set MailingCountry = United States AND apply Zip Code rule + Valid State (US) Rules"

where:

Zip Code and Valid State (US) rules are similar to these: https://help.salesforce.com/articleView?id=fields_useful_validation_formulas_account_address.htm&type=5

... In other words, I don't want the user to have to manually select United States from the picklist the first time they enter an address on a bunch of blank address fields -- it should assume the address is in the US, unless they select otherwise, and apply the US field validation rules, unless they select another country.

I realize technically it doesn't need to set MailingCountry again if it's already United States, but I can't think of a better way. If you don't assume both null and United States to mean "United States", then it could potentially overwrite another Country value with United States.

The problem with all the sample field validation rules as written, is that they assume the Country field is blank or United States. But if you remove any of that logic, it forces them to select a country or performs validation rules on records with no addresses and doesn't let them save the Contact if the address fields and country are blank.

Any help is much appreciated! Thanks