After completing this how-to you will have the ability to create a simple validation rule.
Improve the quality of your data using validation rules. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value.
In this demonstration, we want to create a validation rule that if we sell an After Market product, we want the rule set up that if the discount is greater than 20% then create an Error that will let not let the user save the record, and also create an error to display to let the user know why.
Navigate to After Market Object
Start by going to Setup.
In the Quick Find field, enter Object Manager and click on the Object Manager.
After opening the Object Manager we need to find the object we will be creating the rule for. In this case, search for After Market.
Click on the After Market Object.
Create a Validation Rule
When the Object is open, on the options on the left side of the page select Validation Rules.
Create a Rule Name for the Validation Rule and a Description if desired.
This is where we need to drill down to the field we need to create the rule for. By selecting the After Market in the first selection field it pulls up your options in the next column, we know that the After Market Gross is in the deal so we need to select Deal to open the options that are in the deal, select Aftermarket Gross.
By selecting Aftermarket Gross it will give you the option of inserting this field into the formula field to create your formula.
Now that we have the field, we will be creating our rule from where we can create the formula. In this case, we want to use anything in the Aftermarket gross field if greater than a 20 % discount, create the error. After you make your formula the Check Syntax button will find any errors in your formula before moving forward.
Now that we have created our rule, the next step is to create the error message that you would like the user to see upon trying to save. After creating the error message, click the Save button or Save & New to create another Validation Rule.
Validation Rule is created and displays an error with a message
This will be the error the user sees when they try to save a Deal record that contains a discount greater than 20% of the After Market Gross.