You need to sign in to do that
Don't have an account?

Validation rule for phone number based on user's iso country code
Hi All,
I want to write a validation rule on phone number custom field. I want to check if the phone number cotains the user's iso country code. For example the user creating or updatin the record has its iso country as INDIA. The validation rule must check if the phone number contains +91. I want to write that for many countries.
Thanks,
Anuj
I want to write a validation rule on phone number custom field. I want to check if the phone number cotains the user's iso country code. For example the user creating or updatin the record has its iso country as INDIA. The validation rule must check if the phone number contains +91. I want to write that for many countries.
Thanks,
Anuj
You can use the below code,
IF( Country !='',NOT(REGEX( Phone , "[+][0-9]{2}[' '][0-9]*{10}")),False)
So a phone number like +91 (850) 644-4201 is valid as per the above formula. And you can give a proper error mesage which could make the user fill the record more correctly.
I need to check user's country code and then check. If u are an indian user and u enter +92 and then number, it should throw an error.
Thanks,
Anuj
You can use the below formula in that case,
IF((MailingCountry='US' || MailingCountry='United States') && LEFT(Phone,2)<>'+1', True, IF(MailingCountry='India'&& LEFT(Phone,3)<>'+91', True, IF((MailingCountry='UK' || MailingCountry='United Kingdom') && LEFT(Phone,3)<>'+44', True, False)))
If you have more mailing countries that you use, just take the core formula out of the above one which is,
IF(MailingCountry='<Country Name>' && (LEFT(Phone,3) <> '+<2digits>' ,True,False) and fill it and paste it in the false part of the above formula and do the same logic oif you have many countries to be used.
Take the left pasrt of phone as per the number of digits contains in a country code. For example, for US, it is '+1'. So take LEFT(Phone,2). And for UK(+44) or India(+91), the same is LEFT(Phone,3).
Do let me know if you have any doubts or queries.
Phone Number Should start with +91,+01,+44,+61 following numbers,
how to write error condition for this?
I have a requirement where according to the country (picklist: USA, Canada, Australia, UK, India), the phone number must start its respective country code.
IF(( Country__c == 'US')&& LEFT(Phone,2) <> '+1',True,
IF( Country__c == 'India')&& LEFT(Phone,3) <> '+91',True,
IF( Country__c == 'UK')&& LEFT(Phone,3) <> '+44',True,
IF( Country__c == 'Australia')&& LEFT(Phone,3) <> '+61',True,
IF( Country__c == 'Canada')&& LEFT(Phone,2) <> '+1',True, False)
The above throws an error: Field Country__c is a picklist field. Picklist fields are only supported in certain function
Please assist with the correct function for the requirement.
Please try this:
ISPICKVAL(MailingCountryCode , 'US') && LEFT(Phone,1) <> '1' ||
MailingCountry = 'India' && LEFT(Phone,2) <> '91' ||
ISPICKVAL(MailingCountryCode , 'UK') && LEFT(Phone,2) <> '44' ||
MailingCountry = 'Australia' && LEFT(Phone,2) <> '61' ||
MailingCountry = 'Canada' && LEFT(Phone,1) <> '1'
Did you got the answer.
even I'm looking for regex code where it should accept +61897654324 format.