Lightning Flow : Validating Input Using Flow

What is Flow ?

Lightning Flow is a new service by lightning platform that empowers any business by collecting data and doing something to data in salesforce or external systems. It helps to create and extend the power of process automation to any customer or employee experience.

A Flow has three main building blocks :

  • Elements : These are used to instruct flows what to do. Elements contain Screens, Logic and Actions. So Instructions vary based on what kind of element it is.
  • Connectors : They will define the path that flow takes when it runs. It guides the flow which element to execute next.
  • Resources : These are the containers to represent the given values. You can reference resources throughout your flow.

You can validate what a user enters in a flow screen and provide an error message to guide the user.

Who doesn’t want to get validated data so as to input to ensure the data is clean, correct and useful.

Data validation occur in two locations: 

  1. The point where data from the database is acted upon, for example validating input parameters to an SOQL query.
  2. General validation at the point where data collected from the user is submitted, for example in a web application some validation should occur on the client. 

But what if there is no way to add a validation rule ? The solution is Custom Validation Using Flow.  

So, here, the particular use case which is going to be customized is mentioned below : 

Use Case: To add custom validation to postal code, to validate the length of zip code is 5. 

Flow to tackle the above problem: 

Step 1: Add “Display text” to the screen, just below to Address Component. 

Step 2: Then create a Boolean variable (getAccountPostalCode) to control the visibility of this new Display component and a formula type variable to check the validation of postal code. This is how it looks like: 

Step 3: Now, it’s time to check the output of our formula field (ValidatePostalCode) through a decision element. If it’s true then we will assign the result of the formula variable to the boolean variable (getAccountPostalCode).

Step 4: Assign a variable(getAccountPostalCode) with the formula (ValidatePostalCode).

Step 5 : Add the decision logic in the decision box.

Step 6: Test the created flow.

  1. For the correct input.

Result :

  1. For the incorrect input:

Result :

Hope you’ve enjoyed playing with customizing Flow.

Thanks for your time !! – Subscribe for more updates..!

Want To Know More?

<strong>Juhi Kumari</strong>
Juhi Kumari

Salesforce QA

Leave a Reply