Start tracking your progress
Trailhead Home
Trailhead Home

Create Validation Rules

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.

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.

  1. From Setup, click Object Manager and select Account.
  2. Select Validation Rules, then click New.
  3. For Rule Name, enter:
    Support plan expiration date required
  4. Ensure Active is selected.
  5. For Description, enter: 
    Support plan expiration date is required when account is marked as having support plan.
  6. Enter this formula in the Error Condition Formula box: 
    Has_Support_Plan__c = True && ISBLANK(Support_Plan_Expiration_Date__c)
    Error Condition Formula screen showing Support plan expiration date validation rule formula.
  7. Click Check Syntax to ensure you have no errors.
  8. For Error Message, enter:
    You must enter an expiration date when an account has a support plan.
  9. Select Field as the Error Location and Support Plan Expiration Date as the Field.
  10. Click Save.

Next, create an opportunity validation rule to force users to enter a Close Reason when the opportunity Stage is Closed Lost.

  1. From Setup, click Object Manager and select Opportunity.
  2. Select Validation Rules, then click New.
  3. For Rule Name, enter:
    Close reason required when lost
  4. Ensure Active is selected.
  5. For Description, enter:
    A close reason is required when opportunity is closed lost.
  6. Enter this formula in the Error Condition Formula box:
    ISPICKVAL( StageName ,"Closed Lost") && ISBLANK( Close_Reason__c )
  7. Click Check Syntax to ensure you have no errors.
  8. For Error Message, enter:
    You must enter a close reason when opportunity is closed lost.
  9. Choose Field as the Error Location and Close Reason as the Field.
  10. Click Save.

You’ve created picklists, lookup filters, formula fields, and record types; set up 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!

retargeting