+ Start a Discussion
Gourav JainGourav Jain 

How to Create a Validation Rule in Salesforce.com(Force.com)

what are the validation rules? how to create a validation rule?




Validation Rules: - "Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of "True" or "False." Validation rules also include an error message to display to the user when the rule returns a value of "True" due to an invalid value."


In simplest terms, some rule that you would like to do checks on your system, record. So, Validation Rules are Available in: Group, Professional, Enterprise, Unlimited, and Developer Editions.


To create validation rules:-

1. Go to the Object you would like to create the validation rule on. To get to that object click Setup and then Customize. If it is a standard object like Account, Contact, Opportunity, Product, etc.

2. If it is a Customize Object then click on Setup==> Create==>Objects and then click on the object you like.

3. Now click on Validation Rule and click New.

4. Give your Validation a Name

5. Give it a Description (not needed but helps in the long run and good practice)

6. Check the Active Box to make it Active

7. Error Condition Formula: This is where you place in your expression to validate the field.

8. Now in the Error Message Place in the Error you would like the User to see or get.

9. Error Location: Do you want to display the error on top of the page or next to the field itself. If you want it next to the field then click field and choose your field from the Picklist.

10. Click Save to finish or Save & New to create additional validation rules.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

Gobinath AGobinath A
Hi Gourav,

Please try the below link and I hope it helps.


Anitha SadhasivarajaAnitha Sadhasivaraja
Though Validation rules are OOB functionality in Salesforce, why we are still doing in custom coding. Means we can handle all validation in our classes. what is the difference in these 2 approaches? Need suggestion..