Validation Rules in Salesforce

In this article I will give you 5 validation rules which you should create in your client’s Salesforce org as an Admin. But before that let’s have a quick summary of What are validation rules.

What are Validation Rules in Salesforce?

Validation rules are used to enforce data quality and consistency by validating data entered by users before saving it to the database. These rules are expressions or formulas which check the data and determine whether it meets specified criteria. 

5 Validation Rules Examples

Here are some important validation rules which you can configure in your org:

1. The account number is Numeric 

There might be a scenario where you want your user to enter only numeric values in the Account Number field of Account Object. You can configure the below validation rule for the same.

OR(
ISBLANK(AccountNumber),
NOT(ISNUMBER(AccountNumber))
)

Below is the screenshot of the validation rule.

Now if you try to enter text value in the Account Number field it will give an error message as you can see below.

2. Annual Revenue Range

There could be scenarios where you don’t deal with accounts having annual revenue greater than a specific number. You can enforce this using the below rule.

OR(
AnnualRevenue < 0,
AnnualRevenue > 1000000
)

Below is the screenshot of the rule.

Now if you try to enter annual revenue greater than 1 million then you will get an error.

3. Close Date Must Be a Future Date

Sales reps often select past dates in an opportunity closed date field and you want to restrict them. This can be achieved by the below validation rule.

CloseDate< today()

Below is the screenshot of the rule.

Below is the error you will get when you enter the past date in the opportunity close date field.

4. Prevent Open Cases from Being Reset to New

Sometimes service agents change the status of open cases to New you want to restrict. These can be achieved by below validation rules.

AND(
ISCHANGED( Status ),
NOT(ISPICKVAL(PRIORVALUE( Status ), "New")),
ISPICKVAL( Status, "New")
)

Below is the screenshot of the configured validation rule.

And below is the screenshot of the error message which you will get while trying to set the status of open cases to new.

5. Blank Email or Mobile

There can be scenarios where you want at least one communication detail to be available on contact record like email or mobile number. These can be configured by the below validation rule.

AND(
 ISBLANK( Email ) , 
 ISBLANK( MobilePhone ) 
)

Below is the screenshot of the configured rule.

Below is the error you will get when you leave email or mobile empty.

So these are some common rules which you should create in salesforce org to enforce data quality. If you have any rule in mind then please post in the comment below so we all can learn.

Shubham Lashkan
Shubham Lashkan
Articles: 9

One comment

  1. Please don’t use that close date validation, it will block all future updates on the opportunity, no matter what is the good reason you might want to update it

Leave a Reply

Your email address will not be published. Required fields are marked *