Call Us Today !

How to Create Validation Rules in Salesforce

An organization can have a vast array of data available in their own systems. Hence, there’s always a big chance that some users will enter incorrect or inconsistent data. To prevent this from happening, Salesforce introduced the idea of validation rules. What do validation rules mean, and how are they created in the platform?

Definition of Validation Rules

A validation rule is a set of standards written and applied to a particular field to prevent a user from inputting incorrect data. This rule prevents inconsistencies with data quality and catches errors that future app users may make with their data entries. If, for instance, an app user entered incorrect data on a field, the validation rule set on that field must detect it and prevent the record from being saved to the platform. The app user will see an error message upon his attempt to save the incorrect data record.

Features of Validation Rules

Here are some key points and features about validation rules.

You can execute them once you try to save a new record you made.
A rule typically contains a formula or expression that can evaluate data from one or several fields. Values will return as True or False, based on the set validation rule.
If a validation rule finds a record erroneous, it will display an error message to alert you that the data entered was wrong in a way. The error message will be displayed either at the top of the page or below the field itself.

Creating a Rule

You can set the validation rules on both standard and custom objects.

For standard objects: In the Setup mode, go to Build > Customize, then select the standard object that needs to have a validation rule set. Click on Validation Rules and write the corresponding rule for the object.

For custom objects: From the Setup mode, go to Build > Create > Object. Select the custom object that needs a rule then click on the Validation Rules Section. Proceed to writing the rule.

In creating a validation rule, you need to consider certain properties:

Rule Name – must consist 40 characters, no spaces and special characters included
Description – distinguishes the rule from others; made up of 255 characters or less
Error Condition Formula – an expression that’s used to validate a certain field
Error Message – the message displayed to a user when his data fails to meet the validation rule standards
Error Location – exact page location where the error is displayed
Active – a toggle checkbox that can indicate if the created validation rule is enabled or not

Once done with the validation rule, simply click on Check Syntax to test if it’s running as planned. Click the Save button to finish.

Share this article!

Partager sur facebook
Partager sur twitter
Partager sur linkedin
Partager sur email