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
Nithin Kumar 36Nithin Kumar 36 

Phone number format

I want to format the standard phone number field values. Example value should be 123-456-9876 when we enter as 1234569876 in the phone field? Is it possible?
RD@SFRD@SF
Hi Nithin,

You can update the phone number field with using str replace functions in workflow field update. Or use a formula field to represent the number in this format. 

Depending on your requirement.

Hope it helps
RD
Nilotpal RoyNilotpal Roy
Yes, It's possible using the below formula in Validation Rule

NOT(REGEX(Phone, "((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}"))

Thanks & Regards,
Nilotpal Roy

 
CloudalyzeCloudalyze
Hi Nithin,

PFB the resolution mentioned in the standard Salesforce documentation (https://help.salesforce.com/articleView?id=000181563&type=1) below

Phone numbers containing 11 digits
 
Phone numbers beginning with 1: Data will be saved as a 10 digit number using parenthesis, removing the first digit (1).
Ex: A phone number entered as 12345678901 will be saved as (234) 567-8901
 
Phone numbers beginning with any other digit: Data will be stored as is without any formatting:
Ex: A phone number entered as 23456789012 will be saved as 23456789012.
 
Note: To use a custom formatted phone number, enter a “+” before the digits in the number (Ex: +49 1234 56 78-0)
Ajay K DubediAjay K Dubedi
Hi Nithin,

I would like to make sure all phone numbers are updated to conform to this format:
xxx-xxx-xxxx
I tried to write a workflow rule to address this as follows:
not(and(
len(HomePhone) == 12,
isnumber(left(right(HomePhone,12),3)),
left(right(HomePhone,9),1) == '-',
isnumber(left(right(HomePhone,8),3)),
left(right(HomePhone,5),1) == '-',
isnumber(right(HomePhone,4))
))

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi
Keira ArnotKeira Arnot
The standard phone number format has been elaborated on this blog page. The Salesforce developer community has been doing a good job in this regard. I prefer to check this (https://wenumber.co.uk/numbers/0345-area-code/) wenumber site for 0345 numbers with a discount offer. Keep sharing more like this.