Validation Rule in Salesforce

 

       How to Write a Validation Rule in Salesforce


Validation Rule:- Salesforce has provided a very helpful feature called the “Validation rule” to ensure administrators/developers can create custom validation rules on Salesforce objects. This rule helps to ensure that any record being created or updated qualifies to defined business rules. If not, then developers/ administrators will have to display a required error message.


Validation rule constitutes of:-

Formula — formula to evaluate the business rule. If the formula evaluates to TRUE, a validation error is thrown, else it’s considered as validation success

Error message — error message to be displayed on validation failure.

Location —define a location to display validation error.

 

Follow the step to create a validation rule for object:-

1.       Go to Setup -Enter Object Manager in a quick box -Select Account (Any Object which you want to make validation)

2.       Select the validation rule from the left sidebar.

3.       Click New.

4.       Enter the Name of the rule.

5.       In the Error Condition Formula section defines your criteria to validate the data.

6.       To check the formula or expression for error click on Check Syntax.

7.       In the Error the message section define your message and position which will appear when the user enters the wrong data.

8.       Finally, Save it.

 

Let’s take an example:-

Example 1 –

-You must enter declined reason if an opportunity is marked as Closed lost (Create new declined reason field if required).

 





Output for this validation rule:-



Comments

Popular posts from this blog

Rollup Helper in Salesforce

How to add Leads and Contacts in Salesforce Campaign

Create New Related Record In One Click by Using Quick Action