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
MeghanQFSMeghanQFS 

123-456-789

I want to be able to type 9 digits but have the dashes automatically be inserted after every three digits.
 
I've made the custom field, but I cannot figure out the right formula.
 
Any ideas?
Best Answer chosen by Admin (Salesforce Developers) 
cpierrecpierre
NOT(
OR(
LEN (Custom_Field_c) = 0,
REGEX( Custom_Field_c , "[0-9]{3}-[0-9]{3}-[0-9]{3}")
)
)
 
This reads as...
Three single digits(0-9){3} - A dash 

All Answers

cpierrecpierre
NOT(
OR(
LEN (Custom_Field_c) = 0,
REGEX( Custom_Field_c , "[0-9]{3}-[0-9]{3}-[0-9]{3}")
)
)
 
This reads as...
Three single digits(0-9){3} - A dash 
This was selected as the best answer
MeghanQFSMeghanQFS
Perfect! Thanks.
BUT... Where you have Custom_Field when I type in the name of the field which is SIN it says "Error: Field SIN does not exist. Check spelling."
What do you think?
TCAdminTCAdmin

Hello MeghanQFS,

If it is a custom field it will utilize __c after the normal name. Yours is most likely SIN__c. You can view the name by going to field in setup and viewing the API name.

MeghanQFSMeghanQFS

Yup, that is the right API name; SIN__c, but it tells me that the field does not exist.

 

cpierrecpierre
Hmm, that ones a bit odd. Sorry I don't have an answer for you. Perhaps this is a support issue - as I can get it to work for me
MeghanQFSMeghanQFS
Check out this image and maybe you can see something I'm doing wrong....
 
TCAdminTCAdmin
Hello MeghanQFS,

I think you are looking for a mask which isn't possible in the system at the current time. The REGEX() function is utilized in a validation rule to make sure the user enters the correct format but will not make the user's data format in that method. If you go to Help & Training and do a search for REGEX you will see how it is designed to work.

Your other option is to validate that the user enters the 9 numeric digits. You can then build a workflow and field update that will change that 9 digit value to the correct format of 999-999-999.
MeghanQFSMeghanQFS
I have the Group Edition; can I still build a workflow?
TCAdminTCAdmin
MeghanQFS,

Unfortunately no.