As the title states I'm trying to check if my phone numbers are suitable to be converted to standard format (US only). Specifically, I want all 10 digit phone numbers that do not start with 1 and all 11 digit numbers that only start with 1 and are not in standard format already (XXX) XXX-XXXX.
From this page: https://developer.salesforce.com/forums/?id=906F00000009FN3IAM
I have adapted a formula that does most of what I want, but it is still missing "all 11 digit numbers that only start with one". Here is the formula:
AND(
NOT(
AND(
LEN(Phone) == 14,
LEFT(Phone,1) == '(',
ISNUMBER(LEFT(RIGHT(Phone,13),3)),
LEFT(RIGHT(Phone,10),1) == ')',
LEFT(RIGHT(Phone,9),1) == ' ',
ISNUMBER(LEFT(RIGHT(Phone,8),3)),
LEFT(RIGHT(Phone,5),1) == '-',
ISNUMBER(RIGHT(Phone,4))
)
),
ISNUMBER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone, ".", ''),"-",""),"+","")),
OR(
LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone,".",''),"-",""),"+",""))=11,
AND(
LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone,".",''),"-",""),"+",""))=10,
LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone,".",''),"-",""),"+",""),1)!="1"
)
)
)
Where Phone is a variable that is assigned to the phone field in the record. This formula will return a boolean that will be used to decide if a second formula should be applied downstream.