Automation, Flow, Lightning

Popular Validation Rules for Salesforce Flows including Phone, Email and Address Fields

It is important to build validation rules into your flows. If you skip this step, you will end up with errors, when your users enter information that is not in compliance with the field definition or the validation rules that are built into your field.

My popular validation rules for flows are as follows.

Name fields:

Standard length for Name Fields are 40 for First Name, 20 for Middle Name and 80 for Last Name.

First Name (Text Length)

Error message example:

Your entry needs to be shorter than 40 characters. 

Validation rule:

LEN({!First_Name})<=40

Social Security Number:

Error message example:

Please enter 9 digits for the SSN field. 

Validation rule (this rule allows for dashes as well):

OR( 

REGEX( {!Social_Security_Number} , "[0-9X\\-]{11}"), 

REGEX( {!Social_Security_Number} , "[0-9]{9}") 

) 

Address fields:

Standard length for address fields are 256 for Street Address and 80 for City. The ZIP (Postal) code can be in XXXXX or in XXXXX-XXXX format.

State code

Error message example:

Please enter a State Code consisting of two capital letters. 

Validation rule:

NOT( 

 AND( 

   NOT(ISBLANK({!State})), 

   OR( 

      LEN( {!State}) <> 2, 

      NOT(CONTAINS({!State}, UPPER({!State}))) 

    ) 

 ) 

) 

ZIP (Postal) Code

Error message example:

ZIP code needs to be in XXXXX or in XXXXX-XXXX format. 

Validation rule:

REGEX({!MailingZIP} , “\\d{5}(-\\d{4})?”) 

Revenue (Currency/Number Length):

Error message example:

Your entry needs to be shorter than 16 digits. 

Validation rule:

{!Revenue}<10000000000000000 

Email:

Error message example:

Please enter a valid email address. 

Validation rule:

REGEX({!Email_Address},”[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}”)

Phone number:

Error message example:

Please enter a 10 digit phone number. 

Validation rule:

AND( 

LEN({!Mobile_Phone})=10, 

NOT(REGEX({!Mobile_Phone} ,"^[a-z A-Z]*$")) 

) 

Please also see my other post on keeping phone field values clean using Salesforce flow titled “Keep Salesforce Field Values Clean (Video) in Summer 20 with Flows” here.

Leave a Reply