Flow Action - Save Validation Results

The Flow Action "Save validation results" allows you to save the validation results of Flow Actions - Validate Address, Validate Email and Validate Phone.
Due to Salesforce Governor Limits, this Flow Action can only be used for processing single records. If multiple records are provided the flow will fail. 
In this article, you will learn how to save the validation results of Addresses, Emails, and Phone Numbers. Please read these articles on how to validate Addresses, Emails, and Phone Numbers in a flow.

Step 1 Fill in API Field Name and Assign Variable

1.1 Complete Step 1 till Step 3 from Flow Action - Validate Address when you want to save the validation results for the Address Field.

Complete Flow Action - Validate Email for the email fields and Flow Action - Validate Phone for the phone fields if you want to save the validation results for those type of fields.
1.2 Open the Screen Action and click on "RV - Validate Address".
1.3 At "Field API Name" type the Street Field API Name that is mapped in RV Setup > Object > Address
Then the flow knows which address the results should be validated for.





1.4 Check the 'Manually assign variables (advanced)' checkbox.
1.5 At "Record Validation Result", click in the "Search variables" field and choose "+ New Resource". 
1.6 At "Resource Type", choose "Variable".
1.7 At "API Name", define an API name for the new variable.
1.8 At "Data Type", choose "Apex-Defined".
1.9 At "Apex Class", choose "recordval__Rv2FlowValidationResult".
1.10 Click Done.
1.11 Repeat steps 1.1 - 1.10 to save the validation results for additional Address fields, Email fields, and Phone fields.


Step 2 Store all validation results in a new variable

The validation results from the RV - Validate Address, Email and Phone Action have to be stored in a variable to serve as input for the "RV - Save validation results" Action.

2.1 Open the Lightning Flow Builder.
2.2 From the Elements section, drag a new Assignment to the screen from the toolbox on the left side.

2.3 At "Label", define a name for the assignment. If the API name is not set automatically, make sure an API name is defined as well. 
2.4 At "Set Variable Values", click in the "Search variables" field and choose "+ New Resource". 
2.5 At "Resource Type", choose "Variable".
2.6 At "API Name", define an API name for the new variable.  
2.7 At "Data Type", choose "Apex-Defined".
2.8 At "Apex Class", choose "recordval__Rv2FlowValidationResult".
2.9 Tick the checkbox "Allow multiple values (collection)".
2.10 Click Done.





2.11 Change the operator from "Equal" to "Add".
2.12 At "Value", click in the "Enter value or search resource..." field and choose the Apex Defined Variable you created in Step 2.
2.13 Click on "+ Add Assignment" if you want to store more apex defined variables. 
2.14 At "Variable", click in the "Search variables..." field and choose the same Apex Defined Collection Variable as in the first row.
2.15 Change the operator from "Equal" to "Add".
2.16 At "Value", click in the "Enter value or search resource..." field and choose the next Apex Defined Variable.
2.17 Repeat step 3.13 till 3.16 until all Apex Defined Variables are added.
2.18 Click Done.


You have now stored the validation results of the fields you want to validate in a new variable that can serve as input for the "RV - Save Validation Result" flow action.

Now would be a good time to also create/update a new record with the input from the Screen Component.

Step 3 Use the "RV - Save validation results" flow action

3.1 From the Elements section, drag a new Action to the screen from the Toolbox on the left side.
3.2 In the New Action dialog, search for RV - Save validation results. 
3.3 At "Label", define a name for your action. If the API name is not set automatically, make sure an API name is defined as well. 
3.4 At "RecordId", switch to "Include" and fill in the variable of the created record.
3.5 At "ValidationResults", switch to "Include" and fill in the "Apex Defined Collection Variable".
3.6 Click Done.


Step 4 Connect your actions to the start trigger

Make sure the Screen component, Assignment, and "Save Validation Results" action are connected to the start trigger.




In this example, we're first gathering the field values in a screen. Values are then stored in a variable (assignment). A record is created and the variables from the assignment and the record Id are used as input for the "Save Validation Results" action.

Step 5 Run the flow

Save the flow, give it a name and click "Run".

In the example below a lead is created where the address, email, and phone number are validated and formatted upon entry. The First Name, Last Name, and Company are filled in as well in the flow.



When the flow is finished, the record is created, and the validation results are saved:


 

Having trouble?

Can't find what you're looking for? We are always happy to help.