Sub topic 8
Email, Phone and URL fields
This chapter assumes you can create custom fields in Object Manager and know the difference between a standard and a custom field. It covers three types that store contact details as text but add validation or behavior on top.
What these types have in common
Email, Phone and URL are specialized text fields. Each one stores a string, and each one changes how Salesforce checks input or displays the value. Choosing one over plain Text gives you the built-in behavior without writing a validation rule.
| Type | Maximum length | Built-in behavior |
|---|---|---|
| 80 characters | Checks the format on save. Shows as a clickable mailto link. | |
| Phone | 40 characters | Accepts any characters. Shows as a click-to-dial link where supported. |
| URL | 255 characters | Shows as a clickable link. Opens in a new window or tab. |
An Email field rejects values that are not shaped like an address, such as maria@ or maria.example.com. The check covers format only. It does not confirm that the mailbox exists.
Email fields can be marked unique and can be used as an external ID. They also work with list email and email alerts, because Salesforce knows the value is an address. Plain Text fields do not get that treatment.
Phone
A Phone field does not enforce a format. (415) 555-0100, 415.555.0100 and +44 20 7946 0000 are all accepted. This is deliberate, because phone formats differ by country.
If you need a consistent format, you have two options:
- Add a validation rule that tests the value with
REGEX. - Use a Flow or a trigger to normalize the value on save.
The tip below matters for searches and duplicate matching, since two formats of the same number look different to a query.
A sample validation rule that requires a US number with ten digits:
AND(
NOT(ISBLANK(Phone)),
NOT(REGEX(Phone, "\\(?\\d{3}\\)?[-. ]?\\d{3}[-. ]?\\d{4}"))
)The rule fires when the value is present and does not match the pattern.
URL
A URL field holds a web address of up to 255 characters. It displays as a link. Include the protocol, for example https://example.com. A value without a protocol can produce a broken link in some views.
If you need more than 255 characters, such as for long tracking links, use a Long Text Area. You will lose the clickable link. A formula field with the HYPERLINK function can restore it.
When to choose each one
Common errors
- Using Text for emails. You lose format checking and email features.
- Expecting the Phone type to validate numbers. It does not.
- Storing a URL without
https://. The link may not open as intended. - Making a Phone field unique. Different formats of one number pass the check, so uniqueness fails to prevent duplicates.
Exercise
A team stores customer phone numbers in a Phone field. Duplicates keep appearing, as "(415) 555-0100" and "415-555-0100" on separate records. Marking the field unique did not stop this. Why, and what would you do?
Show answer
Uniqueness compares the stored strings, and the Phone type does not normalize format, so the two values count as different. Normalize the value to a single format, such as E.164, with a validation rule or Flow that runs on save. Uniqueness or duplicate matching then works on consistent values.