In Salesforce, we usually need to use the AND and OR conditions in the validation rule or formula.
In this Salesforce tutorial, we will learn how to use OR and AND Conditions in a Validation Rule in Salesforce. In that, we will see the following topics:
- What is the OR condition in Salesforce?
- How to use the OR condition in a Validation Rule in Salesforce.
- What is an AND condition in Salesforce?
- How to Use the AND condition in a Validation Rule in Salesforce.
OR condition in Salesforce
In Salesforce, the OR condition checks whether any of the conditions that we have defined are true. For example, we have defined conditions c1 OR c2 OR c3 in the validation rule; if any of these conditions are true, then the validation rule will be executed.
How to use the OR condition in a Validation Rule in Salesforce
Let’s consider an example: we need to apply a validation rule to the Account Object’s Name and Email fields. The requirement is that if any field is blank, an error message should be displayed. Here, we can use an OR condition.
1. Navigate to the Account Setup from Object Manager. -> Validation Rule. -> New.
2. Enter the Rule Name. -> Check the Active checkbox to activate the validation rule.
3. Here, we need to enter the logic for Error Conditions in Formula Editor.
OR( ISBLANK (Name) , ISBLANK (Email) )This OR condition applies if any field, either Name or Email, is blank. The record will not be saved.
- OR: It checks if any condition from this gets true, and then the record will not get saved.
- ISBLANCK(): This function checks if the field is blank.
- Name, Email: These are the Account Fields; we can insert them from the Insert Field button.
Next, verify the entered code’s correctness by clicking the Check Syntax button, then click Save.

Step 4: Now navigate to Account Object and try to create a New Account record. Here, you can see I have entered my Name and left the Email field blank. I tried to save the record, but I got an error.

This is how we use the OR condition in the Validation Rule in Salesforce.
AND condition in Salesforce
In Salesforce, the AND condition checks whether all of the conditions that we have defined are true. For example, we have defined conditions c1, c2, AND c3 in the validation rule; if all of these conditions are true, then the validation rule will be executed.
Now, let’s see how to use OR and AND Conditions in the Validation Rule in Salesforce.
How to Use the AND Condition in a Validation Rule in Salesforce
Now, we will take the same example to check what the difference is between the OR and AND conditions; we will change the logic to the AND condition.
1. Navigate to the validation rule where you used the OR condition and change the condition.
AND ( ISBLANK ( Name ) , ISBLANK ( Email__c ) )This AND condition applies if both fields, Name and Email, are not blank. Then, only the record will not be saved. If any of the fields have a value, then the record will be saved.
AND: It checks both conditions; if this gets true, the record will not be saved.
Then, check whether the entered code is correct or not, click on the Check Syntax button, and click on the Save button.

2. Now, navigate to Account Object and try to create a New Account record. Here, you can see I have entered my Name and left the Email field blank. I tried to save the record, but here, the record gets saved because of the AND condition.
If the Name and Email are both left blank, then the record will not be saved.

This is how we use the AND condition in the Validation Rule in Salesforce.
Conclusion
In this tutorial, we have learned how to use OR and AND conditions in validation rule in Salesforce. We have seen what OR and AND conditions are and how they work. We have also covered examples of using OR and AND conditions, and we have seen how they work as a validation rule.
You may like the following Salesforce tutorials:
- Validation Rules in Salesforce
- How to Bypass Validation Rules Using Salesforce Flow
- Salesforce Checkbox Validation Rule
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.