Salesforce Menu

Playing with Validation Rules

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.

After you have defined validation rules, the user chooses to create a new record or edit an existing record.

The user clicks Save. All validation rules are verified. If all data is valid, the record is saved. If any data is invalid, the associated error message displays without saving the record. The user makes the necessary changes and clicks Save again.

You can specify the error message to display when a record fails validation and where to display it. For example, your error message can be “Stock Exceeded.” You can choose to display it near a field or at the top of the page. Like all other error messages, validation rule errors display in red text and are preceded by the word “Error”.

How to create a Validation Rule :
1. Open your object on which you want to apply validation (e.g. here we are choosing Line Item object), scroll down untill you get Validation Rules section as specified below and click New button


2. Once you click on New button, below screen will appear, where you need to define your validation rules (so here we are trying to make you understand that if Line item stock (i.e. Selling stock) is greater than Merchandise Stock (i.e. the stock which we have in our Warehouse) then error message should be encounterred and for this we need to write an Error Condition Formula : Line_Item_Stock__c > Merchandise__r.Merchandise_Stock__c ) and click Save button


Note : Validation rules apply to new and updated records for an object, even if the fields referenced in the validation rule are not included in a page layout or an API call. Validation rules don’t apply if you create new records for an object with Quick Create. If your organization has multiple page layouts for the object on which you create a validation rule, verify that the validation rule functions as intended on each layout. If your organization has any integrations that use this object, verify that the validation rule functions as intended for each integration.

Subscribe Now