Validation Rule for Phone Number in Salesforce

In this Salesforce tutorial, we will learn how to add the validation rule for the phone field in Salesforce. If you want to learn the process of this in Salesforce, you have come to the right place.

Phone Number Validation Rule in Salesforce

Here, we will learn how to add the validation rule for the phone field in Salesforce.

Let’s take a real-life example. Suppose there is a company. I am working in this company managing the Salesforce database for this small business and collecting customer information.

It is also my responsibility to ensure that the phone numbers entered by customers in the phone number field in Salesforce contain a minimum of 10 digits to ensure accurate contact information.

Here are the following steps:

1. Click on the Gear Icon, Select the Setup option, Click on the Object Manager tab that is present on the nav bar.

2. Enter the Contact object in the search box and then select the contact object.

How to add validation rule for phone field in Salesforce Lightning

3. The contact page is open. On the left side of the contact page, there is a validation rule option. Click on this validation rule option.

Add validation rule for phone field in Salesforce

4. Now, enter the information related to the contact validation rule. First, fill in the rule name. Here, we are filling in the rule name as the phone validation rule, and then enter the error condition formula, and we are filling in the error condition formula as LEN(Phone) <> 10.

See also  How to Create a Checkbox Field in Salesforce

Here, we select the len() function and then select the phone field that is used as an argument, and after that, we use the operator that is used to give the maximum phone number length as 10.

Add validation rule for phone field in Salesforce Lightning

5. Here, we are filling in the error message ” Phone must contain 10 digits.” This error message can either appear at the top of the page or below a specific field on the page. Now click on the save button.

Salesforce add validation rule for phone field

6. Click on the App launcher and enter the contact in the search box. Select the contact. The contact record page is open. We want to create a new record. Click on the new button. Now, fill in the information related to the contact.

First, fill in the Name field and then enter the phone field. Here, by mistake, we fill in the nine-digit number and hit the save button. As the validation rule is applied to the phone number field, the error message occurs when the phone number field must contain 10-digit numbers.

Salesforce Lightning add validation rule for phone field

7. Enter the exact 10-digit phone number and click on the save button. Our record is saved, and the contact Mr. King Cassin V record is created. The phone number is shown under this record.

How to add the validation rule for phone field in Salesforce

In this way, we understand how to add the validation rule for the phone number field in Salesforce.

10 Digit Phone Number Validation Rule in Salesforce

Here, we will learn how to add a 10-digit phone number validation rule in Salesforce.

Now, take an example of adding the validation rule to ensure that the data entered into a phone number field follows the particular layout and meets the criteria.

See also  Salesforce Email Field

Let’s suppose I work in a company based in the United States of America. We want to ensure that the phone number entered by users in the Salesforce system is not blank or is entered when creating a new contact record in Salesforce.

Perform all the above steps again, and we get the output like this. The Phone number field contains 10 digits.

Salesforce Classic add a validation rule for phone field

This explains how to add the validation rule for the phone field in Salesforce Classic.

Conclusion:

I hope you read the entire article and get a complete idea of the validation rule for phone numbers in Salesforce. I have also explained all the steps for adding the validation rule for the phone number by taking an example in Salesforce.

You may like to read: