Create Validation Rules
The Rundown
Noah Larkin can now track which accounts don’t have a support plan expiration date, but he also wants to ensure that, going forward, all users enter the support plan expiration date when the Has Support Plan checkbox is selected on an account. Allison Wheeler has a similar request. She’d like to ensure that sales reps enter a Close Reason whenever an opportunity is lost.
Take care of Noah’s and Allison’s requests by creating validation rules, which allow you to specify your own criteria to prevent users saving invalid data in one or more fields.
Note: An important point to keep in mind when working with validation rules is the impact on existing data. Validation rules apply to both future data and current data so the admin may need to populate the required data of the existing records to ensure any future integrations aren't blocked.
Create Validation Rules
First, create an account validation rule that forces users to enter a Support Plan Expiration Date when Has Support Plan is selected.
- From Setup, click Object Manager and select Account.
- Select Validation Rules, then click New.
- For Rule Name, enter:
Support_plan_expiration_date_required
- Ensure Active is selected.
- For Description, enter:
Support plan expiration date is required when account is marked as having support plan.
- Enter this formula in the Error Condition Formula box:
Has_Support_Plan__c = True && ISBLANK(Support_Plan_Expiration_Date__c)
- Click Check Syntax to ensure you have no errors.
- For Error Message, enter:
You must enter an expiration date when an account has a support plan.
- Select Field as the Error Location and Support Plan Expiration Date as the Field.
- Click Save.
Next, create an opportunity validation rule to force users to enter a Close Reason when the opportunity Stage is Closed Lost.
- From Setup, click Object Manager and select Opportunity.
- Select Validation Rules, then click New.
- For Rule Name, enter:
Close_reason_required_when_lost
- Ensure Active is selected.
- For Description, enter:
A close reason is required when opportunity is closed lost.
- Enter this formula in the Error Condition Formula box:
ISPICKVAL( StageName ,"Closed Lost") && ISBLANK(Close_Reason__c)
- Click Check Syntax to ensure you have no errors.
- For Error Message, enter:
You must enter a close reason when opportunity is closed lost.
- Choose Field as the Error Location and Close Reason as the Field.
- Click Save.
You’ve created picklists, lookup filters, formula fields, and record types; set up custom record pages, page layouts, and field history tracking; and established validation rules. Using these tools, you’ve enabled the ops, sales, and service teams to do their jobs better and more efficiently by customizing how they work with the important data they need day to day. Good work, Admin!