Basically I am trying to create some email templates that send out to our users that contain a phone number. A lot of these phone numbers are formatted with no parathensis or dashes, and are in the form 1234567899, but our users would like them to appear on the template as (123) 456-7899.

I know we could do this with a formula field that will break it up and add the characters, but I am wondering if there is a way to tell the template directly to format the merge field being provided in this manner.


Yes - this is possible if you use a visualforce email template:

({! LEFT('1234567899', 3) }) {! LEFT(RIGHT('1234567899', 7), 3) }-{! RIGHT('1234567899', 4) }

If you place the above in a visualforce email template it will format string '123456789' with the text you want.

Replace '1234567899' with merge field like:

 ({! LEFT(relatedTo.Phone , 3) }) {! LEFT(RIGHT(relatedTo.Phone, 7), 3) }-{! RIGHT(relatedTo.Phone, 4) }
  • Exactly what I was looking for! Thanks so much – Frank Evers Feb 4 '20 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.