Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Can Adding an extra condition to a regex validation rule work efficiently?

Asked by Ankur Vaish Apr 22, 2021 1.2K views 1 answer
Share

About this question

I wrote a validation rule that specifies the amount of characters in the field and the way those characters are supposed to be placed. However to go with different writing styles I want to be able to add an extra regex condition to my rule. Here is a part of the existing rule:

AND( NOT(REGEX(BillingPostalCode, "\d{6}" )), 1 = CASE(BillingCountryCode, 'CN' , 1 , 'IN' , 1 , 'KZ' , 1 , 'RO' , 1 , 'RU' , 1 , 'SG' , 1 , 0 )), AND( NOT(REGEX(BillingPostalCode, "^(\d{4}(\-\d{3})?)?$")), 1 = CASE( BillingCountryCode, 'PT', 1 , 0 )),

so based on the code above China, Kazakhstan, Romania... etc have to have 6 characters in their post code. Portugal has to have either 4 or 4-3(8) Is there a way to add additional rules to the already existing rule so that I can have:

D-

PL-

ES-

FIN-

D -

All Optional in the beginning of the postal code. I haven't managed to do it in any way.

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.