Creating and keeping high-quality data is difficult, but it's even harder to identify and fix a dataset full of mistakes.
Faulty CRM data can lead to negative consequences for a company, including impeding operations, generating unreliable reports, and demanding that users manually verify each record. One common cause of these errors is manual data input. Whether due to lapses in attention or accidental keystrokes, mistakes are bound to happen when entering data into a form. To reduce these errors, CRM systems have validation rules in place to notify users of mistakes and block incorrect data from being entered.
Validation rules can be used to handle situations like the following:
- Preventing a form from being saved if a social security number doesn't contain nine characters.
- Alerting an agent when a traveler above the age of 40 is added to a physically challenging trip.
- Stopping a sales representative from offering a discount when a company has not purchased a minimum number of user licenses.
- Ensuring an IBAN number matches the specified format.
Availability
Users need Module Customization profile permission to create validation rules.
Basics of validation rules
Validation rules in Zoho CRM are set up for specific fields, such as the Discount field in a deal's record. If a user inputs an invalid value and attempts to save the record, the CRM will display an error message or alert. Please note that the alert option shown below is being released in a phased manner and may not be available in your account.
Validation rules determine if an entry is valid by comparing the input with the criteria or function set for the rule.
- Validation rules are layout-specific, meaning it's possible to set up different validation rules for the same field on different layouts.
Configuration options in validation rules
Options are available at each stage of the configuration flow when setting up a validation rule. The choices made will vary depending on the specific use case. Let's look at some of these options.
Validation preference
Let's say you have a company policy that prohibits discounts that exceed 15%, and that sales reps are encouraged to avoid offering discounts over 10%.
In this scenario, you can set validation rules that completely disallow values above 15% and allow values above 10%, while also displaying a warning for sales reps that discounts above 10% are not ideal.
You can manage situations like this by setting the validation preference as follows:
- Stop with error (which prevents the saving of the record)
- Allow by alert (which allows the saving of the record after getting confirmation from the user)
The stop with error option prevents users from saving changes to records when a field contains an invalid value.
The allow by alert option allows users to save changes made to records but displays a warning and requires confirmation in order to complete the changes.
Error location
You can also choose where error messages are displayed on the form. You can choose:
- On primary field to display the error message right next to the field.
- Top of page to display it at the top of the form.
In most cases, the values users enter into different form fields are not interdependent. For this reason, if there's a validation error for any given field, it's best to display the error near that specific field. This enables users to easily identify and correct any input errors. The
on primary field option is optimal for these scenarios.
In complex and data-intensive forms, validation errors may occur due to interdependencies between the values entered in different fields. In these cases, consolidating all validation errors in one place can help users efficiently resolve issues. Choose the top of page option in such scenarios.
Move the error message to the top if there are dependencies. Mix and match both options (On primary field and Top of page) to help users quickly resolve errors.
Validation on
A field's validation can be triggered in one of the following modes:
Save only: Choose this option if you want the validation to happen when the user clicks the Save button. Please note that all validation rules configured for that layout will be triggered when you click Save.
- Field verify and save: Users may need to validate an important field quickly before proceeding to other fields. For instance, you may want to validate the IBAN number before proceeding to fill other details.
Validation of that specific field will occur upon clicking this button. The validation will be performed when saving the record as well. This allows for a quick verification of fields before proceeding to fill in other related fields.
The field verify and save option is not available in:
- Canvas pages
- Convert /mass convert pages
- Stage closed popup (that appears when a deal is closed)
- Details required popup (that appears when a layout rule is executed for a quick edit in the record detail page), and
- Field of lookup popup.
Validation type
Fields are validated according to the parameters you've set in a validation rule, which can be defined in two different ways.
- Using criteria: You can easily set up validation rule parameters using a visual builder. Choose the primary condition to activate the rule and the secondary condition to apply it to specific records. You can also customize the error or alert message for each secondary condition.
- Using a function: You also have the flexibility to create a validation rule using a function if the previous type doesn't cover your use case. This provides you with complete control over your validation rule, enabling you to implement complex business logic and check data from other applications.
Note
- Validation rules that use functions aren't currently compatible with validation preference and error location options.
- You can only set a validation preference for the save only option.
- Error location is only accessible when the validation preference is set to stop with error.
- When the field verify and save mode is enabled, the error message will be displayed near the primary field, and you won't be able to save the record with the entered value.
Criteria-based validation rules
The following sections specifically address criteria-based validation rules. In the remainder of this document, when we refer to "validation rules", we're specifically referring to this type of validation rule.
To learn about validation rules using functions, read
Create validation rules using functions.
Parts of a validation rule
- The primary field is the field being validated. In our running example, this would be the Discount field.
- During validation, the primary field value is checked against one or more primary conditions. You can specify up to 10 primary conditions, such as "Not between 0 and 15" or "Not between 0 and 10".
- You can decide if the primary condition is checked for all records or for subsets of records. Each primary condition can have up to five secondary conditions. For example, we can check whether the Discount (primary field) is less than 15% (primary condition) for deals from the NA and MEA regions (secondary condition). We can have another secondary condition for deals in the EU region. This way, we can validate a field differently based on values in other fields.
Each secondary condition can have one error/alert message. This message content is customizable.
Multiple error messages may be displayed for a field simultaneously because all primary conditions are checked when the validation rule is executed.
Execute rule on
You can decide when the validation rule should be executed. This is because you can define the criteria in two ways:
- You can set unwanted values in the primary condition(s) and specify that an alert should be triggered when the condition is satisfied. For instance, you could define the condition as a discount value exceeding 15 percent (undesirable) and notify the user when the input value fulfills this condition.
- Alternatively, you can set desired values in the primary condition(s) and indicate that an alert should be triggered if they are not satisfied. Specify the primary condition as a discount value below 15 percent (preferred) and notify the user if the input value doesn't meet this condition.
To create a validation rule
- Go to Setup > Customization > Modules and Fields.
- Select the module for which you want to create the validation rule.
- In the [Module] page, click the Validation Rules tab.
- Click Create New Validation Rule.
- In the Create Validation Rule pop-up, perform the following actions:
- Select the layout that the field you wish to validate belongs to.
- Select the field to validate.
- Select the validation type as Based on Criteria.
Select either Save Only or Field Verify and Save for Validate on.
- Click Next.
- In the Validation rule editor page, specify the primary condition to initiate the rule. For instance, if you want to validate the discount field to keep out discounts more than 15%, your primary condition will be "Discount > 15%".
- Click Done.
Select an Execute rule option from the dropdown list. In our example, we've defined the undesired value in the primary condition, so we'll select When criteria is met.
- Customize the error message according to your needs. In our case, we want to forbid the entry of a discount value greater than 15% for certain regions, so our error message will be, "You cannot provide a discount over 15% for deals from the NA and MEA regions."
- Configure the secondary condition. Set the other options like validation preference and error location if available. If you want the error message to be displayed for all records, leave it as-is. If you want to apply it to a subset or create multiple conditions, you'll have to edit it. In our example, we want this error message to be displayed only for deals from the NA and MEA regions. Accordingly, we can do the following:
- Click the More icon and then click Edit.
- In the Which records would you like to apply the rule to? pop-up, select Choose based on specific conditions.
Define the criteria as needed.
If you wish, you can drill down to select exactly the records you need by adding more criteria using the + button.
- Click Done.
- Click + if you want to add another secondary condition and repeat the previous steps to configure it.
- Click Add another option to add another primary condition.
- A fully completed validation rule will look something like this:
- Click Save (at the top-right of your screen). You've successfully created your validation rule.
Note
- If a field, used in primary or secondary conditions, is updated via a workflow rule, Blueprint, API, import, or webform, this field update will take precedence. This means that the validation rule will be overwritten by the field update. As a consequence, CRM will accept the value entered as a result of the field update over the validation rule. Learn more about the consequences of this here.
- In cases where you've created both a validation rule and a Blueprint
validation for the same field and both have different conditions, the
Blueprint validation will override the validation rule. This is true as
long as the record is within a blueprint to which the Blueprint
validation is applicable. When a record has exited a process, the
validation rule is then effective.
- If records generated via webforms meet the validation rule criteria, they'll be submitted for manual record approval.
- Below are the numbers of conditions allowed within a validation rule:
- 10 primary conditions per rule
- Five secondary conditions per primary condition
- Five criteria per secondary condition
- Validation rules aren't supported for multi-select lookups, multi-picklists, multi-user field, formula fields, auto-number fields, image upload fields, and multi-line fields.
- You can validate images using Zia. To learn more, see Zia Vision.
- Validation rules are supported in the following areas:
- Create (web version)
- Quick create (web version)
- Edit (web version)
- Quick edit (Ajax, web version)
- Convert (single and mass)
- Kanban view
- Copy customization
- Sandbox
To edit a validation rule
- Go to Setup > Customization > Modules and Fields.
- Select the module for which you want to create the validation rule.
- In the [Module] page, click the Validation Rules tab.
- Click the validation rule that you want to edit.
- Make changes in the validation rule editor and click Save.
To deactivate a validation rule
- Go to Setup > Customization > Modules and Fields.
- Select the module for which you want to deactivate a validation rule.
- In the [Module] page, click the Validation Rules tab.
- Toggle the Status for the validation rule.
- In the pop-up that appears, click Deactivate now.
To delete a validation rule
- Go to Setup > Customization > Modules and Fields.
- Select the module for which you want to delete a validation rule.
- In the [Module] page, click the Validation Rules tab.
- Hover over validation rule that you want to delete.
- Click the Trash icon that appears.
- In the pop-up that appears, click Yes, Delete.