- Salesforce Platform Developer I Certification Guide
- Jan Vandevelde Gunther Roskams
- 301字
- 2021-08-20 10:02:12
Validation rules
Validation rules are used to make sure that the data entered in fields adheres to the standards you have specified for your business.; for example, making sure that phone numbers always have the same format, or that a field cannot be left blank based on the input or value of another field. If a value does not meet your validation rules, then the user will not be able to save the record. A validation rule is made of a formula or expression to check the criteria and an error message, which will be shown to the user if the values do not meet your specified criteria. The formula evaluates the data in one or more fields, and then returns either true or false. Validation rules ensure data quality in your org.
If the formula returns true, then the defined error message is displayed and the record cannot be saved. The formula can be referenced with more than one field and can also be a cross-object formula. While setting the error message, you can decide to show it next to a certain field or on top of the page.
Validation rules will run while performing operations through an API (through Data Loader, for example), on web-to-lead creations, and on web-to-case submissions. So, make sure that you design your validation rules so that they will not interfere unintentionally with these functionalities. In some scenarios, you may need to disable the validation rules while you import or update data, and then reactivate the rules afterward. Alternatively, you may exclude a specific user or profile in the validation formula so that it doesn't execute when the operation is run, as that specific user or as a user with that profile; this means that they can perform data loads without validation rules firing.