Using Dynamic Components and Flow To Guide Users
Sometimes, users just need a bit more guidance. Maybe it’s for a new process or maybe it’s a complex process where users often forget important steps.
Path is a solution for this. It allows you to pick a picklist field and display different information based on the field. The issue with path is users can collapse the information. It’s also static, unless you’re creative, but that’s another post.
Sometimes you want something that simply in your face and screams “Hey! Don’t forget to do this!”
This is where Dynamic Lightning Components and Flow come in.
A Dynamic Component Scenario
I love Approval Processes in Salesforce. The setup is fairly easy and Approval Processes can help an organization ensure that things are being done correctly according to process.
One thing I really dislike is the lack of transparency. When you create an approval process you setup entry criteria. These are criteria the record must meet to enter that particular approval process. This is very useful with objects that may have multiple approval processes for different record types or different business processes. The downside is that these entry criteria are not readily visible to an end user. When I click “Submit for Approval” and my record doesn’t meet any Approval Process’s entry criteria, I simply get a message “No applicable approval process was found.”
That’s not very helpful. They know the record needs to be submit for approval, but they don’t know why it’s working. What should they do? Call the administrator? Review pages of process documents? Cry softly into their beer as they slowly pour gasoline over their computer and set it on fire in frustration?
No one wants that. That’s terrible option. Who ever wants to read process documents?
In classic, I would create a formula field that would prompt the user to fill in details or tell them it was ready to submit for approval. It worked, but it was ugly. Plus, that field always had to be present regardless if the user was no-where near needing the information. The other big problem is formula limitations. There’s only so big a formula can be, which limits what you can do.
So, let’s solve this with Flow and Dynamic Lightning Components!
How it Flow and Lightning Dynamic Components Work
First, you’ll need a Flow with Screens. I won’t go into details how to build this particular Flow. The one I’m using has a Fast Lookup to get the Opportunity, a decision element to choose which of the 2 screens to display.
So below is my Opportunity. For my process, users need to get approval whenever they are asking for a discount. The trick is we want to make sure other fields are completed: Next Step, Lead Source, and Type. You’ll see in our screenshot below, I’m not asking for a discount and our Flow is not visible.
Next, I update my Opportunity so I’m giving a 5% discount. Bam! Our Flow appears and tells me a list of fields that I need to update.
So I update the Next Step and Lead Source, but I’m still missing Opportunity Type. Our Flow is still visible and the list of required items is updated
Finally, I update my Type field. Our Flow now states that we need to submit for approval. That’s much nicer than trying to change the stage and get that ugly validation error.
How cool is this? Once I’ve submitted for approval, my flow disappears. Wonderful! Adding Flow to a Lightning Page and making it dynamic is really easy.
- Drag the Flow Component to the page
- Select your filters under “Set Component Visibility
Make sure you have a variable set to at least Input Only so you can pass the record ID. That way you can query the record the user is looking at and determine which screen to show them.
I personally love this solution. There’s one problem with it. Due to how Lightning works, the page doesn’t always fully refresh when a user does an edit. Because the page doesn’t get refreshed, the component doesn’t re-run. In my scenario, the Flow screen won’t update when a user edits unless the page gets refreshed. This has been inconsistent for me. Sometimes it automatically refreshes, sometimes it doesn’t. That makes this less helpful. I’m hoping to find a work around for this problem so I can really take advantage of Flow and Dynamic Components.
The good news is that the visibility of the component does update when a user edits – without refreshing the page. It’s a strange inconsistency to me that I’m sure there’s a technical explanation.
How will you use Dynamic Components in Lightning Experience? Do you want to see a video of how I built this Flow?
Let me know in the comments! Thanks for reading.
Don’t miss a post! Sign up to receive email notifications on new posts
Help keep the site running
I run this site, the podcast, and my training videos for the community. I do incur some costs. I greatly appreciate if you can help me out by checking out my affiliates and – if you shop amazon – start your search on my site.