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
nonprofnonprof 

Need Help w/ Validaiton Rule for account and contact address fields

I am trying to create a validation rule that will make the Account Billing Country and the Contact Mailing Country fields required and contain values from a specific list (i.e. Country = Argentina or Bolivia or Colombia and nothing else). So far I have only been able to make the fields required. I am having trouble defining the correct formula for the pick-list of acceptable values. I tried:

 

AND( LEN( BillingCountry ) = 0, CONTAINS("Argentina || Peru || Bolivia || USA || Canada || Ghana || Indonesia || Malaysia || Taiwan || Mexico || Nigeria || Pakistan || South Africa || Uganda || India || Philippines || Armenia || Russia", BillingCountry))

 

But it is not giving me an error message when I mis-spell one of those countries nor when I enter something not on the list.

 

Any help would be appreciated.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
JakesterJakester

Hi nonprof,

 

I think the specific problem with the code is that you want it to change the = to a > on the LEN() function, so it would be 

 

 

AND( LEN( BillingCountry ) > 0, CONTAINS("Argentina || Peru || Bolivia || USA || Canada || Ghana || Indonesia || Malaysia || Taiwan || Mexico || Nigeria || Pakistan || South Africa || Uganda || India || Philippines || Armenia || Russia", BillingCountry))

 

 BTW,whenever providing code you can use the Insert Code button on the toolbar (hidden just to the left of the icon with clipboard with a blue W on it).

 

More generally, I'd recommend you consider the excellent integration from www.postcodeanywhere.com - they have a drop-down with every country and then they can turn that full country name into a 3 digit country code (United States becomes USA) plus they can autofill addresses so you're sure you've got a real address. All this for a very affordable price. We're a very happy customer of theirs.

 

Good luck!