Return to site

Opportunity Validation Rule to Require Multiple Fields Validation Rule

Business Problem:

Opportunities in Salesforce utilize a standard field called Probability which is tied to the stage and forecasting. Once an Opportunity reaches certain probabilities businesses may want to require certain fields to have a value.

Validation Rule Solution:

AND(Probability > 50,
OR(
ISNULL(First_Field__c),
ISNULL(Second_Field__c),
ISNULL(Third_Field__c)
)
)

This Validation Rule is relatively simple but there are a few gotcha's that I want to breakdown here that can be big headache's if you don't know how they work.

First, the probability ignores the "%" symbol so you don't need those in your formula. Additionally, notice that I did not put a "," behind the ISNULL(Third_Field__c) statement. This is because this is the last statement in the OR() statement and you don't need any additional commas inside that statement.

So why not put all this in one big AND() statement?

Here's why. If you put everything in an AND() statement everything must be true in order for the validation rule to trigger. In the business case, First_Field__c,Second_Field__c, Third_Field__c each need to be filled out. However, if they are all included in the AND() Statement, if one of the fields is filled out the validation rule would not trigger. Hence, the use of OR()!