Validation rules are quite important especially at the time when the data quality has to be maintained. Data is an essential part of any organization and the quality of data that is inserted by the user can be improved easily by applying the validation rules. In these rules, records are saved if the input is fine, otherwise, in case of any conflict, the error is displayed and records are not saved. Salesforce applications can be created with the validation rules for that Salesforce has provided certain features. In this article, we will discuss the steps that are followed to create these validation rules.
What are the Validation Rules?
Validation rules are used to test that whether the data that is entered by the user follow and meet the standards that are specified by you before the step to save the records. The rules of validation may contain expressions or formula that is used to evaluate the data, the rules may return Boolean values that can be true or false. In case, if the validation rule results in True value then an error message can also be displayed to show the rule validity.
Workflow validation rules can also be specified that consists of a series of actions that can reflect the business process. The workflows are usually started and initialized when any specific field or record meets certain criteria. These workflows can automate standard internal procedures and processes that can save time across the organization. Workflow rules are like containers of workflow instructions that may include validation rules.
Read: What are Salesforce Workflow Rules? How to Create Workflow Rules?
How do Validation Rules Work?
Now, you might have been familiar with the validation rules and why they are used. Mainly validation rules are used to validate the data that is being given by the user. The user can create one or more validation rules to validate data and if the rule violated, an error message is usually displayed on the screen. Some facts related or associated with validation rules are:
- The validation rules are usually executed when the user save data.
- If the validation rule contains an evaluation expression or formula then it may return True or False values. The error message is usually displayed at the top of the page or below the field that is associated with the error message.
- When the rules are being written for the fields or the set of the fields then anyone of the below-listed action gets executed when you will click on the save button:
- Salesforce executes the validation rules that are specified by the user and if data is found validated then the record is saved otherwise it is not being saved.
- If invalid data is being entered by the user then an error message will be displayed
- In case if the field that is associated with the validation rule is not displayed in the page layout, still the validation rule will be applied and if the rule fails in validation then an error message will be displayed on the screen.
How to Create Validation Rules?
Validation rules are not specific and the user can create the rule as and when required. For single or multiple fields, the rules can be created. Here we are going to discuss these rules and the way in which they are created. Below-listed steps are followed to create the validation rules for any Salesforce applications:
Read: Top 10 Salesforce Automation Tools: Which Do You Use
- In the Salesforce application dashboard, go to the Setup and then select Object Manager and select Account afterwards.
- From here, select Validation Rules and click New.
- In Rule Name field, enter text like “Expiration Date is Required”.
- Select Active by ticking the field and make sure that is selected.
- In Description box, enter the description like “Expiration date is required for the accounts that are valid”.
- In the box of Error Condition Formula, you can enter following formula: Has Support Plan c = True && IS BLANK (Expiration Date c)
- As per this formula, the condition “Has Support Plan c” and ISBLANK fields validates true then the error message that will be defined by the user be flashed otherwise it will not be displayed.
- Here, Check Syntax to make sure that no error is there in the field.
- Now, you should enter the error message like given below “An expiration date is expected to validate the account”
- Now, select the field as error location and the validation field must also be saved
- Finally, click on ‘Save’.
Now create opportunity validation rule to force users so that they can enter a close reason for the opportunity stage that is closed lost. Following steps are to be followed to create the opportunity rules in Salesforce:
- Go to Setup and click Object Manager then select Opportunity
- Now select Validation Rules and click New
- Now enter the Rule Name and enter the text like “When lost provide the close reason”
- Select Active
- In Description box enter the description like “To close the opportunity a reason is required”
- In error condition box enter the formula “ISPICKVAL (Stage Name, “Closed Lost") && ISBLANK (Close Reason c)”
- Now click on Check Syntax to make sure that there is no error
- In Error message text box enter the text like “A close reason is required when the opportunity is closed or lost”
- For Error Location choose the Field and same has to be chosen for Close Reason specification
- Click on Save
In this way, you can create the validation rule for opportunities. For any number of fields, the rules can be created moreover you can select one or more fields for single rue. Means if you require more than one field for validation then choose accordingly.
The rules are essential for validation and can include formula fields, lookup filters, and record types. You can also set up page layouts and track the field history as well. Even sales, service and ops team members can also perform their job in a better way if they will use these validation rules to validate the data. They can even be customized and can be used to import data. The validation rules can be easily defined by even any non-technical person if they want to validate a field.
Read: What is Collection in Salesforce?
Salesforce Vs. Different Technologies
- AWS & Fundamentals of Linux
- Amazon Simple Storage Service
- Elastic Compute Cloud
- Databases Overview & Amazon Route 53
5 days 02 Feb 2020
- Intro to DevOps
- GIT and Maven
- Jenkins & Ansible
- Docker and Cloud Computing
-1 day 27 Jan 2020
- Data Science Introduction
- Hadoop and Spark Overview
- Python & Intro to R Programming
- Machine Learning
6 days 03 Feb 2020
- Architecture, HDFS & MapReduce
- Unix Shell & Apache Pig Installation
- HIVE Installation & User-Defined Functions
- SQOOP & Hbase Installation
7 days 04 Feb 2020
- Salesforce Configuration Introduction
- Security & Automation Process
- Sales & Service Cloud
- Apex Programming, SOQL & SOSL
0 day 28 Jan 2020
- Introduction and Software Testing
- Software Test Life Cycle
- Automation Testing and API Testing
- Selenium framework development using Testing
-1 day 27 Jan 2020
- BA & Stakeholders Overview
- BPMN, Requirement Elicitation
- BA Tools & Design Documents
- Enterprise Analysis, Agile & Scrum
-1 day 27 Jan 2020
- Introduction & Database Query
- Programming, Indexes & System Functions
- SSIS Package Development Procedures
- SSRS Report Design
3 days 31 Jan 2020
Receive Latest Materials and Offers on Salesforce Course