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
DamziniDamzini 

Validation Rule, Shipping country

i have a re-occurring problem with unclean data being entered though 'shipping country' field and would like to set a validation rule with a list of every country so that if the value entered doesn't match a listed country an error message appears. i have tried many different avenues but cant seem to find the right code to make it work and would be grateful if anybody has a solution.

phiberoptikphiberoptik

Do you have access to workflow rules? Would you be open to going the route of custom Country picklist field where the value selected is then populated into the standard ShippingCountry field via workflow?

 

Otherwise, a validation rule is just going to compare the entered value to a long list of Country names you put in the formula and spit a generic error out. If they put in USA and you want United States, it isnt going to say "Country should be United States" because it wont recognize what they attempted to enter. if you did want the validation rule, it would just look like this:

 

AND(
          ShippingCountry <> "United States",
          ShippingCountry <> "Canada", 
          ShippingCountry <> "Mexico",
          etc,
          etc,
          etc,
)  

 

DamziniDamzini

I am under intruction not to use a custom field and i had tried using the method you have shown but it exceeded the number of characters i could use. is there an alternative way of doing it?

phiberoptikphiberoptik

Are all 196 countries relevant to you? Can you cut the list down?