|Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions|
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. Review these considerations before implementing validation rules in your organization.
How Salesforce Processes Validation Rules
Salesforce processes rules in the following order:
- Validation rules
- Assignment rules
- Auto-response rules
- Workflow rules (with immediate actions)
- Escalation rules
- When one validation rule fails, Salesforce continues to check any additional validation rules on that field or any other field on the page and displays all appropriate error messages at once.
- If validation rules exist for activities and you create an activity during lead conversion, the lead converts but a task isn’t created.
- Validation rules are only enforced during lead conversion if validation and triggers for lead conversion are enabled in your organization.
- Campaign hierarchies ignore validation rules.
- Salesforce runs validation rules before creating records submitted via Web-to-Lead and Web-to-Case, and only creates records that have valid values.
- Validation rules continue to run on individual records if the owner is changed. If the Mass Transfer tool is used to change the ownership of multiple records, however, validation rules won’t run on those records.
Validation Rule Field Restrictions
Validation rule formulas don’t or can’t refer to:
- Compound fields, including addresses, first and last names, and dependent picklists and lookups
- Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies
- Merge fields for auto-number or compound address fields such as Mailing Address
Merge fields for individual address fields, such as Billing City
, are OK to use in validation rule formulas.
In addition, validation rules behave like this with regard to other fields and functions in Salesforce:
- The detail page of a custom activity field doesn't list associated validation rules.
- Because updates to records based on workflow rules don’t trigger validation rules, workflow rules can invalidate previously valid fields.
- You can’t create validation rules for relationship group members.
- Because roll-up summary fields aren’t displayed on edit pages, you can use them in validation rules, but not as the error location.
Lookup Filters vs. Validation Rules
Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter if:
- You want to improve user efficiency by limiting the number of available options in a lookup search dialog.
- You want to improve user efficiency by automating filters on lookup search dialogs that your users manually set.
Use a validation rule if:
- You're close to the maximum number of lookup filters allowed.
- You must implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use ISNEW if the rule should only apply on record creation, or ISCHANGED if the rule should apply when a field changes.