Save Validation Results - Flow Action

Last published at: July 16th, 2024
Delete

The Flow Action "Save validation results" lets you save the validation results of Flow Actions - Validate Address, Validate Email and Validate Phone.

Delete

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 that were validated in a flow. For the validating itself, see articles Addresses, Emails, and Phone Numbers.

Step 1 Fill in API Field Name and Assign Variable

  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.
  2. Open the Screen Action and click on "RV - Validate Address".
  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.
  4. Check the 'Manually assign variables (advanced)' checkbox.
  5. At "Record Validation Result", click in the "Search variables" field and choose "+ New Resource". 
  6.  At "Resource Type", choose "Variable".
  7. At "API Name", define an API name for the new variable.
  8. At "Data Type", choose "Apex-Defined".
  9. At "Apex Class", choose "recordval__Rv2FlowValidationResult".
  10. Click Done.
  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.

  1. Open the Lightning Flow Builder.
  2. From the Elements section, drag a new Assignment to the screen from the toolbox on the left side.
  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. 
  4. At "Set Variable Values", click in the "Search variables" field and choose "+ New Resource".
  5.  At "Resource Type", choose "Variable".
  6. At "API Name", define an API name for the new variable. 
  7. At "Data Type", choose "Apex-Defined".
  8. At "Apex Class", choose "recordval__Rv2FlowValidationResult".
  9. Tick the checkbox "Allow multiple values (collection)".
  10. Click Done.
  11. Change the operator from "Equal" to "Add".
  12. At "Value", click in the "Enter value or search resource..." field and choose the Apex Defined Variable you created in Step 2.
  13. Click on "+ Add Assignment" if you want to store more apex defined variables. 
  14.  At "Variable", click in the "Search variables..." field and choose the same Apex Defined Collection Variable as in the first row.
  15. Change the operator from "Equal" to "Add".
  16. At "Value", click in the "Enter value or search resource..." field and choose the next Apex Defined Variable.
  17. Repeat step 3.13 till 3.16 until all Apex Defined Variables are added.
  18. Click Done.
Delete

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

  1. From the Elements section, drag a new Action to the screen from the Toolbox on the left side.
  2. In the New Action dialog, search for RV - Save validation results.
  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.
  4. At "RecordId", switch to "Include" and fill in the variable of the created record.
  5. At "ValidationResults", switch to "Include" and fill in the "Apex Defined Collection Variable".
  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: