You need to sign in to do that
Don't have an account?
sheeba S
Phone code should displayed according to country
Hi all,
I want to write a validation rule where picklist value country is US the phone number should display with country code +1 and Australia +61 and India is +91
I have tried this
ISPICKVAL( Country__c , "UK")
AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+44]{3}[1-9]{1}[0-9]{9}"))
ISPICKVAL( Country__c , "USA")
AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+1]{2}[1-9]{1}[0-9]{9}"))
ISPICKVAL( Country__c , "India")
AND( NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+91]{3}[1-9]{1}[0-9]{9}"))
ISPICKVAL( Country__c , "Australia")
AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+61]{3}[1-9]{1}[0-9]{9}"))
)
Thank you in advance
sheeba
I want to write a validation rule where picklist value country is US the phone number should display with country code +1 and Australia +61 and India is +91
I have tried this
ISPICKVAL( Country__c , "UK")
AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+44]{3}[1-9]{1}[0-9]{9}"))
ISPICKVAL( Country__c , "USA")
AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+1]{2}[1-9]{1}[0-9]{9}"))
ISPICKVAL( Country__c , "India")
AND( NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+91]{3}[1-9]{1}[0-9]{9}"))
ISPICKVAL( Country__c , "Australia")
AND(NOT(ISBLANK(Phone_c)),
NOT(REGEX(Phone,"[+61]{3}[1-9]{1}[0-9]{9}"))
)
Thank you in advance
sheeba
IF(ISPICKVAL( Country__c , 'USA') && NOT(ISBLANK(Phone)) &&NOT(REGEX(Phone,"[+1]{2}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'India') && NOT(ISBLANK(Phone)) && NOT(REGEX(Phone,"[+91]{3}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'UK') && NOT(ISBLANK(Phone)) && NOT(REGEX(Phone,"[+44]{3}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'Australia') && NOT(ISBLANK(Phone)) && NOT(REGEX(Phone,"[+61]{3}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,' ') && NOT(ISBLANK(Phone)) && NOT(REGEX(Phone,"[0-9]{10}")),
TRUE,
FALSE)))))
You can change it as per your needs.
All Answers
IF(ISPICKVAL( Country__c , 'USA') && NOT(REGEX(Phone,"[+1]{2}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'India') && NOT(REGEX(Phone,"[+91]{3}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'UK') && NOT(REGEX(Phone,"[+44]{3}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'Australia') && NOT(REGEX(Phone,"[+61]{3}[1-9]{1}[0-9]{9}")),
TRUE,
FALSE))))
However, this has no validation on the Phone field if User selects None as the Country. Meaning, if you have not selected any country, user can type in a 11 digit number or a 5 digits one. Record will still get saved.
IF(ISPICKVAL( Country__c , 'USA') && NOT(ISBLANK(Phone)) &&NOT(REGEX(Phone,"[+1]{2}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'India') && NOT(ISBLANK(Phone)) && NOT(REGEX(Phone,"[+91]{3}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'UK') && NOT(ISBLANK(Phone)) && NOT(REGEX(Phone,"[+44]{3}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,'Australia') && NOT(ISBLANK(Phone)) && NOT(REGEX(Phone,"[+61]{3}[1-9]{1}[0-9]{9}")),
TRUE,
IF(ISPICKVAL(Country__c,' ') && NOT(ISBLANK(Phone)) && NOT(REGEX(Phone,"[0-9]{10}")),
TRUE,
FALSE)))))
You can change it as per your needs.