Skip to main content

Create Validation Rules

Learning Objectives

After completing this project, you’ll be able to:

  • Enforce data integrity with validation rules.
  • Create roll-up summary and formula fields.
  • Automate business processes with workflow tools.

Introduction

Within the Salesforce Platform there are a number of features and tools that let you streamline and automate your business processes. For example, if users are supposed to check the Out of State box every time they submit an out of state travel request, wouldn’t it be nice if that step was done automatically? How about an approval process? Your application might not be adopted if users still have to send an email for approval from their manager and other executives. As you discover in this project, the Salesforce Lightning Platform makes business process automation a snap and doesn’t require any code.

Note

Before you can do this project, you must complete the Build a Data Model for a Travel Approval App and Customize the User Interface for a Travel Approval App  projects. The work you do here builds on the work you complete in those projects. 

Make sure to use the same Trailhead Playground for all the projects in this trail. 

Launch Your Trailhead Playground

You complete this hands-on project in your own personal Salesforce environment, called a Trailhead Playground. Get your Trailhead Playground now by first logging in to Trailhead, and then clicking Launch at the bottom of this page. Your playground opens in a new browser tab or window. Keep the playground window open while you do this project. After you complete the project steps in your playground, come back to this window and click Verify step at the bottom of this page.

Create Validation Rules

Let’s start with validation rules. Validation rules let you set up business-specific criteria to prevent users from saving invalid data in one or more fields. A validation rule evaluates a formula when a record is saved. If a rule’s criteria aren’t met, users see a custom error message and the record doesn’t save. If a rule’s criteria are met, the record saves. Use validation rules to improve data quality by applying conditions, ensuring proper formatting, and enforcing consistency.

Let’s create a validation rule to enforce that a trip end date must always be greater than (>=) or equal to the trip start date. 

  1. Click Setup and select Setup.
  2. Click Object Manager and then click the Down arrow icon. This provides a list of recent objects you’ve edited.Object Manager with recent records displayed.
  3. Select Travel Approval to open the configuration page for the Travel Approval object.
  4. Click Validation Rules.
  5. Click New.
    The Travel Approval Validation rule configuration window
  6. Enter the following values.
    • Rule Name: Trip end date after start date
    • Active: Make sure to keep this selected/checked.
    • Condition Formula:
      Trip_End_Date__c < Trip_Start_Date__c
      When writing a validation rule, your condition formula should return “true” for your error condition.
    • Error Message: Trip end date must be greater than or equal to start date
    • Error Location: Select Field and pick Trip End Date as the location for the error
      The Travel Approval Validation rule configuration window with values
  7. If everything looks good, click Save.
  8. Next, click the Back to Travel Approval link.

Great job! You added a validation on the Travel Approval object to ensure the trip end date is after the trip start date. In the next section, you add a roll-up summary field to total up the trip expense items.

Salesforce 도움말에서 Trailhead 피드백을 공유하세요.

Trailhead에 관한 여러분의 의견에 귀 기울이겠습니다. 이제 Salesforce 도움말 사이트에서 언제든지 새로운 피드백 양식을 작성할 수 있습니다.

자세히 알아보기 의견 공유하기