2

On a layout, if I update a phone number, Salesforce will automatically format it like a phone number if it can.

But if I change it on the backend, like through apex or the developer console, it will not format automatically. And I have some validation rules that depend on that pre-formatting.

Is the function that Salesforce uses to format phone numbers like that available to call programatically?

edit

The question at MobilePhone as HyperLink asks if it's possible to hyperlink a phone number on the page layout. My question is about if it's possible to use Salesforce's built-in phone formatting function programmatically, without having to use the page layout.

edit 2

The nature of these validations is that the numbers that get checked for follow the regex /\(\d{3}\) \d{3}-\d{4}(?: x\d{1,5})?/i. It doesn't behave properly if the phone number isn't in that format.

This isn't usually a problem, since the layout automatically forces that format. But when editing through apex or query editor, that same format forcing does not occur. So I'm trying to figure out if Salesforce makes the function available that does that formatting.

2

1 Answer 1

1

Answering my own question.

It turns out, the thing I was looking for does not exist. The function that Salesforce uses to format phone numbers on the layout is not available for programmers to use.

I've posted an idea here to, hopefully, change that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .