Let us continue with my Lightning Flow, ‘Getting Started’, series. A few months ago, I published an article to help you better understand Flow screen elements by taking a real-time example. In that blog, we discussed how to create a static Flow screen – A Static Flow screen always displays previously added fields.
If you didn’t get a chance to read it yet, do it now! It will significantly improve your knowledge of Lightning Flow.
- Getting Started with Lightning Flow Designer – Part 2 (Do You Know How Screen Element Bestows Power on Lightning Flow Builder?!)
Let us take our knowledge of Flow a notch up! Let us learn how to create a dynamic Flow screen.
Business Use Case
Edward Backhouse is working as a System administrator at GurukulOnCloud. Edward’s Manager requested him to create a form that looks like the following screenshot:
Edward has to accommodate one more requirement – display a ‘Street’ field whenever the City is Mumbai; or else, don’t display the ‘Street’ field.
Pause! Make sure you understand the requirements. Ready?
A solution for the above business requirement
If you are a Salesforce Developer, who knows how to create a Lightning Component, fulfilling the above requirement will be a breeze. But, if you don’t have development experience, it may be a nightmare! Even if you know how to write code in Salesforce, it is best practice to first try and see if you can conjure up a declarative solution.
Let us use Lightning Flow and Screen Element to solve the above business requirement. Perform the following steps to create the solution using the new Lightning Flow Designer:
- Log-in into your developer org.
- Navigate to Process Automation Setting. Then select ‘In Lightning Experience, use the enhanced Flows page and separate Paused and Scheduled Automations page’ checkbox. The new enhanced Flows page in the Lightning Experience includes standard, and custom, Flows on a single page. Standard Flows are built by Salesforce; and, custom Flows are built by users or partners.
- Navigate to Setup (Gear Icon) | Setup | Process Automation | Flows.
- You’re now on the Flow management page. Based on your current org setting, you may see the following buttons:
- Now click on the New Flow button, it will open a pop-up. Perform the following actions on the pop-up screen:
- Next, we will use the Screen element to create a form. Drag and drop a Screen element onto the Lightning Flow Designer. Then, follow the steps as shown in the video:
- The next step is to add another Text field to capture Street details to Screen Element. Drag and drop a Text input field onto screen element – Check out the video for step-by-step instructions:
- Add filter conditions, and logic to Street screen component’s field properties to show or hide it based on the value a user enters in the City field. Check out the video for step-by-step instructions:
- Once done, Save the Flow and name it Dynamic Flow Screen, with Type: Screen Flow. Do not forget to activate the Flow by clicking on the Activate button.
- Woohooo, you have just created a dynamic Flow using Lightning Flow Builder.
It’s time to test the Process
From now onwards, if a user enters ‘Mumbai’ – as a value in the City field – then, the Street field will display. If anything, other than ‘Mumbai’, is populated in the City field then the Street field will be hidden!! So, to experience the magic, click on the following video:
I hope you learned something valuable today and understood how to dynamically display fields in Lightning Flow Screen! Who knew? that learning could be so much fun!!
–> Please feel free to add constructive comments and insights to the blogs.
Proofreader: - Munira Majmundar