Blog Post

How To Create Validation Rule

How To Create Validation Rule

Validation rules validate if the user entered data in a record meets the standards you define before the user can save or update the record.

Let's take a use case where the Universal container app has been developed for a service agent where they can create or update new Account records but the client needs a data validation where the service agent can not create or update the account record if the Account Ownership is “Public” then the standard Annual Revenue should be required.

Now, let’s see step by step how to create a validation rule as a Salesforce Admin.

Step 1: Setup -> Object Manager -> Account - Validation Rule.

Validation Rule Setup

Step 2: At Right side on the top of the screen a button presents i.e., "New" click on it.

Validation Rule New Step

Step 3: A screen displayed contains the following fields as shown in the screenshots, try to fill all the details i.e., “Rule Name" and try to write the expression using the tabs: Insert fields, Insert Operator, and functions

Create Validation Rule New

Provide the Rule name for our validation i.e,"AnnualRevenue_Required_For_Public_Owner" . As the Ownership is a picklist field we have to use the function "ISPICKVAl" then we have to insert fields and try to create the expression as shown in the screenshot.

Create Validation Rule New

Check the syntax then write the message  what to be displayed in the "Error message" such as “For Public companies Annual Revenue cannot be null”           

Select the desired place where to display the error message and then click on "Save".

Step 4: Our Validation Rule has been implemented. Now, it's time to check it.

Step 5: Goto-> Account Tab -> New

Step 6: Fill all the necessary fields and try to keep the Ownership field to public and do not fill anything in the Annual Revenue field

Create New Account Record

Step 7: Click on Save 

ERROR message appears on the screen as shown in the screenshot

Create New Account Record

Again try to provide Annual Revenue and save the account record

Create New Account Record

Now this time the message displayed "Account has been created" as shown in the screenshot.

Create New Account Record

Conclusion: Here we have got a detailed understanding of how to create a simple validation Rule on the standard object where it helps any organization to prevent bad data and improve organizational productivity.

Happy learning

Written By: Ashutosh Tiwari     

Leave a Comment