Skip to main content
I want to validate a field with a different format dependign on the value ina pick list shoudl I use a case o or if statement

 

This si what I want to do 

 

IF (AND(BillingCountry  = "United Kingdom",

 

AND(NOT(REGEX(VAT_Number__c ,"[A-Z]{2}[0-9]{9}")), NOT(ISBLANK(VAT_Number__c ))))

 

AND

 

IF(AND(BillingCountry  = "Ireland",

 

AND(NOT(REGEX(VAT_Number__c ,"[A-Z]{2}[0-9]{7}[A-Z]{1}")), NOT(ISBLANK(VAT_Number__c ))))))

 

The top validation works without the IF when it is on its own.
1 件の回答
  1. 2015年6月22日 12:01
    Hi Olivia,

     

    I would write separate validation rules for each country that way you can show the error message to the users base on the Billing Country.

     

    Your Validation rules will be like below

    AND(

    BillingCountry = "United Kingdom",

    NOT(ISBLANK(VAT_Number__c)),

    NOT(REGEX(VAT_Number__c ,"[A-Z]{2}[0-9]{9}"))

    )

    ............................................

    AND(

    BillingCountry = "Ireland",

    NOT(ISBLANK(VAT_Number__c)),

    NOT(REGEX(VAT_Number__c ,"[A-Z]{2}[0-9]{7}[A-Z]{1}"))

    )

     

     
0/9000