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
Anand Avinash DosapatiAnand Avinash Dosapati 

how to check first 3 numbers of a phone number is equal to 011

Hello Gurus,

I am trying to write a validation rule on the standard Phone field which fulfils the following. The value should be accepted only if it starts with "001" otherwise a validation error should be thrown.
I have tried both the following and were successful in checking the prefix but failing in other cases.

1. 
LEFT(Phone, 3) <> "001"

2.
 AND(
NOT(ISBLANK(Phone)),
NOT(REGEX(Phone,"[001]{3}[1-9]{1}[0-9]{9}"))
)
Danish HodaDanish Hoda
Hi Anand,
May I know in which cases, these are failing?

You could use:
AND(
NOT(ISBLANK(Phone)),
LEFT(Phone, 3) <> "001"
)
Anand Avinash DosapatiAnand Avinash Dosapati
Hello Danish,

The result is the same for using the LEFT function alone and the one you have suggested.
It is throwing the error if the given prefix is neither or not provided.
I have one question here, LEFT being the string function could be used for PHONE fields?
 
Danish HodaDanish Hoda
Yes Arvind, the LEFT function would work for Phone fields as well as the Salesforce takes sit as string(text) value.
Anand Avinash DosapatiAnand Avinash Dosapati
I am confused, then why it is not acceptable when 011 is prefixed
Danish HodaDanish Hoda
Hi Anand,
0011 will not give Validation error, while 011 will give as it is checking as the prefix "001"
Anand Avinash DosapatiAnand Avinash Dosapati
Danish, the value I am trying to give is (011)(2/3 digit country code)(10 digit phone number)

User-added image
Anand Avinash DosapatiAnand Avinash Dosapati
Hi Danish,

These are working.
LEFT(Phone, 3) <> "011"
NOT(LEFT(Phone, 3) ="011")
NOT(BEGINS(Phone, "001"))
dikky nicdikky nic
as Anand said 
it works
upsers (https://www.upsers.mobi/)
 
Morishka WillamsMorishka Willams
It is really informational.It helped me out with the ultimate resolution.I want to include that if any informations or service is required not only for this but also for accounting,vat,tax,debt,excise,outsourcing of accounting fell free to consult with the most reliable  debt management solutions (https://thestepchange.com/debt-information/debt-management-solutions)   who are serving their clients and also enterprise for over than a decade with 100% assurance and assistance.
Suraj AroraSuraj Arora
I am confused about it too.... it's not working.
Airtel Customer Care (https://www.airtelcustomercarenumbers.in/)