What is a Validation Rule?
Validation rules in Salesforce are the rules which contains a formula expressions that validates our data and returns a value of “True” or “False.
- Validation rule contain Formula expressions.
- It evaluate the data entered by the user.
- Validation Rule displays error message to user when the enter invalid values.
- We can create Validation rules in Salesforce for Objects, fields, campaign members etc.
Examples of validation Rules.
- Quantity cannot be Negative.
- A field to hold only certain values.
- Zip code, phone number to entered in certain format.
Let us check with out applying a Validation Rules to Quantity field in Sample Object.
In Sample object we have a field called Quantity. Let us create a record in Samples and enter the quantity value as negative.
As shown above the quantity field is -5o. In general the quantity field must not be negative. In this case we have to apply validation rules. When ever a user enters negative value for a field Quantity then a error message must be displayed to Enter a positive value. Here we have to restrict user by entering negative value.
How to create Validation rules in salesforce?
To create validation rules in salesforce go to Setup | Build | Create | Objects | Sample | Validation Rules.
- Click on new Button to create new validation rule in Sample object.
- Enter Rule Name.
- Click on Insert field and enter the syntax.
- Check Syntax whether it has any errors or not.
- Enter Error message.
- Enter Error location.
- Now click on Save button.
After creating Validation rule in Salesforce we can not enter negative value for Quantity. If we enter negative value an error message will be displayed at the top of the page as shown above. The record will only get saved when a quantity field is positive value.
How to Activate / Inactivate a validation Rule?
A validation rule in Salesforce can be activated or Inactivated. To de activate Salesforce validation rules follow the steps given below.
Go to Object | Validation Rule | Edit the Validation Rule.
- Click on Edit Button.
- Uncheck the active Button to deactivate Validation rule in Salesforce
- Finally click on Save button.
0 comments:
Post a Comment