What are Validation Rules?
Validation Rules verifies that the data a user enters in a record meets the standards you specify before the user can save the record.
How does a Validation Rule work?
- User enters invalid value and attempts to save.
- validation rule uses a boolean statement to evaluate data.
- if error condition is true, save is stopped and the use sees an error message.
What do we use Validation Rules for?
We use to them to:
- improve data integrity
- make a field conditionally required
- prevent the entry of invalid data values directly by users or by other systems
- enforce role-specific, profile-specific, or user-specific constraints
What does the IsChanged(field) function do?
Checks if the field’s value is different from its prior value, and returns TRUE if the values differ. Otherwise, returns FALSE
What does the PriorValue(field) function do?
Returns the previous value for the field.
What does the IsNew() function do?
Checks if the record is new, and returns TRUE if it is new. Otherwise, returns FALSE
How do you enforce conditionally required fields?
Create a validation rule to enforce conditional required behavior.
How do you enforce proper data format?
Create a validation rule using the REGEX function to enforce proper data format.
What are some examples of when you could you want proper data format?
- phone numbers
- zip codes
- billing states
- driver’s license numbers
- credit card numbers
What is Regular Expression (regex)?
Ben’s Definition 1: String that we use to specify a format that we want our format to match.
Ben’s Definition 2: Format specification where we lay out the string format that we expect the values were getting to follow and whenever those values are provided they’re matched against our regex string.
How do you enforce data consistency?
Create a validation rule with VLOOKUP to enforce data consistency
What is the VLOOKUP function?
returns a value by searching for a matching value on a custom object
it can ONLY be used in the validation rules
How do you prevent data loss?
Create a validation rule that prevents records from being added or deleted.