What Is Salesforce Validation Rule?: Assignment-6 Implementing Business Logics Using Validations
What Is Salesforce Validation Rule?: Assignment-6 Implementing Business Logics Using Validations
Validation Rules
• It can contain a formula or expression that evaluates the data in one or more fields &
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
true due to an invalid value/data.
Types of Validation
1. System Validation
• System Validation are enforced by salesforce like numbers should be in a valid format.
The TODAY function returns the current date. The <> (Not Equal) operator determines if a value is
not equal to another value (if it is either less than or greater than the other value.)
In the example, the validation rule determines if the year of a given date is not equal to the year
of today’s date. A value of "True" indicates that the data entered by the user contains an invalid
value. That is, if the user enters a date that is not in the current year, the validation rule returns a
response of "True" and sends an error message.
Field Value
Validates that a custom date field contains a date within the current
Description:
year.
Formula: YEAR( My_Date__c ) <> YEAR ( TODAY() )
Error Message: Date must be in the current year.
Error
My Date
Location:
A value of "True" indicates that the data entered by the user contains an invalid value.
That is, if the user enters two values whose difference exceeds the $20,000 salary range, the
validation rule returns a response of "True" and sends an error message.
Field Value
Validates that the range between two custom fields, Salary Min and Salary Max, is
Description:
no greater than $20,000.
(Salary_Max__c - Salary_Min__c) > 20000
Formula:
Error
Salary range must be within $20,000. Adjust the Salary Max or Salary Min values.
Message:
Error
Salary Max
Location:
The NOT function determines if the inverse of an expression is true. In the example, the validation
rule determines if an account number is both not blank and not a number.
A value of "True" indicates that the data entered by the user contains an invalid value. That is, if
the user enters a non-numeric value for an account number, the validation rule returns a response
of "True" and sends an error message .
Field Value
Validates that the Account Number is numeric if not
Description:
blank.
AND(
NOT(ISBLANK(AccountNumber)),
NOT(ISNUMBER(AccountNumber))
Formula:
)
Copy
Error Message: Account Number is not numeric.
Error
Account Number
Location: