Validation Rules

Validation Rules Validation Rules in Salesforce are used to ensure the integrity of data and records. They can be written as either expressions or formulas and can be as simple or complex as required but inevitably relies on whether the statement is true or false. How To Create a Validation Rule Go to Setup in […]

Validation Rules

Validation Rules in Salesforce are used to ensure the integrity of data and records. They can be written as either expressions or formulas and can be as simple or complex as required but inevitably relies on whether the statement is true or false.

How To Create a Validation Rule

  1. Go to Setup in the top right corner,
  2. Go to Object Manager then search for the Object you want the Rule on,
  3. In the menu on the left, go to Validation Rules,
  4. Click New

There are 3 components that make up a Validation Rule,

  • The name of the Validation Rule,
  • The formula, &
  • The error message

Common Expressions

PRIORVALUE() – Checks the value of the field prior to it being updated to the new value

ISBLANK() – Checks to see if the field has no value

AND() – Allows you to build up complex logic where multiple statements must be true

OR() – Allows you to build up complex logic where either statement can be true

Examples

Example 1

When changing an Account’s county to Lancashire, the country must be United Kingdom

ISPICKVAL(County=”Lancashire”)
&&
NOT(ISPICKVAL(Country=”United Kingdom”))
Example 2

If an Opportunity is worth more than £1 million, a Project Manager must be assigned.

Amount >= 1000000
&&
ISBLANK(Project_Manager__c)
Cameron Ofoluwa
WRITTEN BY

Cameron Ofoluwa

22 Year Old Salesforce Developer @ Pogust Goodhead & Founder of SFDXHours.

Leave a Reply

Your email address will not be published. Required fields are marked *