Validation Checker Flow Action

Validation Checker Flow Action

Created by Eric Smith


This Post was most recently updated on: 6/12/22
Current Version: 1.6


Don’t your users just love it when they see this on their screen?

The fun really starts when you get this email in your inbox.

You could certainly take the time and effort to add a bunch of decision elements and recreate all of your validation rules in your flow.  I bet it would be even more exciting trying to keep all of that maintained.  

Wouldn’t it be nice if your Flows could check for and trap Validation Rule failures, missing required fields, lookup filter violations, text overruns and Duplicate Rule failures?

Well now they can with this simple Check Validation flow action.  

Before you attempt a Create Records or Update Records element in your Flow, add this simple Flow Action and pass it a single record or a collection of records.

This action will check your record(s) and let you know if there would be any Validation Rule errors, field size overruns, lookup filter violations, missing required fields and Duplicate Rule errors if you tried to create or update the record(s).

All this is done before you try to do something that would cause the Flow to fail with an unhandled fault.  You get to determine what to do next and what information you want to present to your user.


You can also use this action as part of your Fault Paths. Instead of just handling the fault without knowing exactly what it is, you can get the error(s) that caused the fault and act on them as you see fit.


In this Flow, a Toast Message will be displayed with any errors and the User will be given a choice of whether or not they want to Try Again or Exit.


You can specify which field from your record you want to include in the error messages to help identify which record(s) failed.

The action returns an isError boolean value along with a text message of the individual errors.  

Validation Rule Failures

Missing Required Field Error

Text Field Size Error

You can set an optional input attribute to have the Validation Checker review all Duplicate Rules when you are providing records to be inserted.

You can even specify an optional input attribute to use this action instead of the Create Records or Update Records to actually perform the inserts and updates if no errors are generated.  If you perform a successful insert of new records, the new record ID(s) will be returned by the action.

Take control of your automations and no more worrying about Flows crashing when User provided values won’t pass Validation Rules or other input errors.


Restrictions

  • If there are multiple types of errors, only one type of error will be returned.
  • If any Text fields are over their size limit, only those errors will be returned.
  • If any Validation Rule fails, all Validation Rule failures will be returned.
  • If any Required Fields are missing, only those errors will be returned.
  • If any Lookup field values violate the defined Filter, only those errors will be returned.
  • If specified in the attributes, Duplication Rules will be checked on new records.
  • Fields over their size limit are handled first, followed by Validation Rules, followed by Required Fields, followed by Filter violations, optionally followed by Duplicate Rule checks.

Attributes

AttributeTypeNotes
INPUT
Input RecordSObjectAny Standard or Custom SObject Record
Required: Provide either a Record or Record Collection, not both
Input Record CollectionSObject CollectionAny Standard or Custom SObject Record Collection
Required: Provide either a Record or Record Collection, not both
Record Identifier Field API NameString (Field API Name)The record’s value for this field will be included as part of the error message.
NOTE: The field must be included in the Record or Record Collection.
Optional, Default: Id
Check duplicate rules on new records?BooleanSet to True if you want the action to check Duplication Rules when adding new Records.
NOTE: This attribute will automatically reset to false if more than 150 new records are being inserted
Optional, Default: False
If no errors, commit inserted & updated records?BooleanSet to True if you want the action to upsert the record(s) if there are no errors
Optional, Default: False
OUTPUT
isErrorBooleanTrue if there were any errors
errorMessagesStringA single string that includes the error message for each failing record
firstInsertedIdStringIf the commit attribute is set to True and there are no errors, this will be the recordId of the first inserted record 
insertedIdCollectionString CollectionIf the commit attribute is set to True and there are no errors, this will be a String collection of the recordIds of all of the inserted records

Notes

  • Prior to Summer ’21, there is a Salesforce bug that will cause a validation error when the record being inserted has values in any picklist fields

Installation

Production or Developer Version 1.6

Sandbox Version 1.6


Release Notes

6/12/21 – Eric Smith – v1.6

Added custom SVG image for the flow builder canvas (auto-layout only)

5/5/21 – Eric Smith – v1.5

Automatically disables the duplicate check option on inserts of more than 150 records to avoid a “too many DML statements” error

4/30/21 – Eric Smith – v1.4

Fixed default value for Commit Records to be False

3/27/21 – Eric Smith – v1.3

Fixed the default values for the optional attributes

3/13/21 – Eric Smith – v1.2

Added optional attribute to run Duplicate Rule check when adding records.


Previous Versions

Production or Developer Version 1.5

Sandbox Version 1.5

Production or Developer Version 1.4

Sandbox Version 1.4

Production or Developer Version 1.3

Sandbox Version 1.3

Production or Developer Version 1.2

Sandbox Version 1.2

Production or Developer Version 1.1

Sandbox Version 1.1


View Source

Source Code