The Dynamic Flow Component (DFC) allows you to further extend your use of auto launch and screen Flows within Lightning Experience and is inspired by a conversation between SFDCWizard and myself at Dreamforce 2017.
In this release you can use this Lightning Component on Record Pages and in the Utility Bar. It will monitor the users record navigation and edits and run a specific Flow based on rules you define. Additionally the component allows Flow logic to show toast messages, navigate to other records, tabs and interact dynamically with the Utility Bar.
Demonstration and setup videos
- Basic Setup
- Setting up Flows
- Record Update and Page Refresh
- Record Notifications
- Creating a Child Record and Navigating to it
What else can i do with this?
- Redirect or refresh the current page once a Flow completes
- Run Flow logic to determine another Flow to run based on field values
- Run Flow logic automatically as the user navigates or edit records
- Display toast messages to remind the user of a task or important fact
- Utilize the Utility Bar to implement a notification system
- Run Flows in the Utility Bar that refresh as the user navigates
- Run Flow logic to automatically open the Utility Bar if closed
- Much much more...
I decided to extend a package i started over a year ago, called Flow Toolbelt to contain this new component. I would recommend installing this package, unless your want to contribute to the code of this open source project. You can see the latest install link in the README file from the GitHub repo associated with Flow Toolbelt.
Preparing your Flows
You can use both auto launch and screen Flows with DFC. For now lets focus on screen Flows. Create a simple Flow with an input SObject variable named flowtb_record and add a single Screen element. Configure the screen element to display information from the record passed in the flowtb_record SObject variable. The record fields populated are based on the record layout shown (using the Lightning Data Service). You can of course use the Flow lookup element to retrieve other fields or related records as needed.
Usage with the Utility Bar
Use the App Manager under Setup to add the Dynamic Flow component per this Trailhead module here. There is no specific configuration, just decide on the label, icon and size of the panel that will popup when user opens the utility bar component.
Once configured, refresh your browser and navigate to any record of your choice. Click to open the utility bar component you just added and you should see the following.
The guidance given by the component informs you what to do next and how to make the configuration specific to the object your currently viewing, Case in the example shown above. The Dynamic Flow Component custom metadata type allows you to associate a specific Flow to run when the user navigates to records associated with the given object.
Next navigate back to the record you chose earlier and you will see it runs the Flow you configured and displays the case number! Next navigate to another record from the same object and the Flow is automatically re-run. You will also find that if you edit the record the Flow also re-runs and sees the latest record changes.
Performing Actions on Finish
When the user clicks Finish, the Flow will reset as normal. However you can also perform one or more of the following actions by assigning specific output variables in your Flow that DFC inspects to drive calls to applicable Lightning APIs and Utility Bar API. This approach is intended to be somewhat generic (or at least easily extensible by community developers) to allow for more flexibility in accessing a broad range of the navigation and notification features available in Lightning Experience.
Showing a Popup Message
Before your Flow ends use the Assignment element to assign a set of output variables as follows to show a popup / toast message as shown below. Assign the flowtb_event variable the value of e.force:showToast and set the variables flowtb_param_title and flowtb_param_message accordingly.
NOTE: Use variables defined as output, otherwise DFC will not see them. You can also set other parameter values to further customize the appearance and duration of the message, as described in the developers docs here.
Navigating to a Record
To automatically navigate the user to a given record, such as one the Flow just created. Assign flowtb_event variable the value of e.force:navigateToSObject and set the flowtb_param_recordId to the Id of your desired record.
Closing the Utility Bar
If you are running DFC within the Utility Bar, you can automatically close it on behalf of the user once your Flow completes. Assign the flowtb_minimize_utility variable any value you like. This can optionally be used in combination with flowtb_event as well.
Running Auto Launch Flows
Sometimes you might want run Flow logic in the background or before the user sees a screen based Flow. Auto launch Flows can be used by DFC to run automatically in the background as the user navigates or edits records. The output actions of these Flows can be any of the above and the following actions.
By setting the optional variable flowtb_flow to the name of a given Flow, the DFC will automatically run that flow when the current one completes. This allows you to dynamically control which screen Flow to run based on record details.
Utility Bar Notifications
The Utility Bar is a relatively new feature in Lightning Experience, but is well worth more of your time if you have not explored it, even for non developers. You may want to start with my Dreamforce 2017 session Lightning Experience as a Platform, past blogs and the official docs. One of the coolest features is the ability for components in the Utility Bar to be highlighted dynamically, this allows you to build a notification system.
Use auto launch Flows that use the flowtb_record variable to conditionally set the flowtb_utility_highlighted variable (any value is fine). You can then draw the users attention to the Flow you want them to run by clicking the Utility Bar to open it. DFC will automatically remove the highlight for you btw.
Opening the Utility Bar
You may want to go a bit further than just highlighting the utility bar, by automatically opening it under certain conditions. To do this set the flowtb_open_utility variable (value does not matter). If the user did not have the utility bar open before hand DFC will automatically close it when the user navigates away from the object.
There is quite a bit of potential with the design of DFC to do more actions than those described above. With a few more tweaks it could drive the default field values shown by Record Create Dialog, as well as implement Lightning Quick Actions, meanwhile i am keen to see what folks do with this initial version.
While researching an issue with auto launched Flows during development of this component i came across some blogs by Doug Ayers. He has been following the same train of thought as myself in respect to detecting record editing. Doug and I had a brief chat and we will hopefully be teaming up on further DFC work, thanks Doug!
Finally i created a Success Community Chatter Group for this component. Feel free to join and post any questions or ideas you have. You can also report bugs and enhancement ideas via the GitHub Issues tab. Enjoy!
Pingback: Introducing the Dynamic Flow Component — Andy in the Cloud – SutoCom Solutions
January 9, 2018 at 7:23 am
Thank you for sharing great article related to dynamic flow. i want to contribute article related to salesforce.
January 24, 2018 at 7:58 am
Your video tells us how to create a childrecord via the Utility bar. We want to make a button (on account for example) that calls the flow that creates a child record (opp) and opens that record. Can you tell us how to do that
January 26, 2018 at 10:41 pm
Sure just drag the Component on the record page and it will Work just the same. If you want an actual button displayed along with the others, that’s something on my backlog
March 25, 2018 at 6:17 pm
As of Spring 18 can create a button to launch your flow via Quick Actions
December 4, 2018 at 11:05 am
This is really great idea. One thing I can’t seem to get passed is its use in custom objects that end in Customobjectname__c. How does one add it as a custom metadata type under Setup?
December 15, 2018 at 12:17 pm
Have you tried putting Customobjectname__c into the Dynamic Flow Component Name field?
January 9, 2019 at 5:47 pm
I hit the same issue–
When you add a custom object name, like Invoices__c, to the Dynamic Flow Component Name field (as directed in the utility bar message) the error returned is:
“Custom Metadata Record Name: The Dynamic Flow Component API Name can only contain underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.”
Second note: instructions say that you have to tell the component that your flow is an autolaunched flow, by marking the custom metadata record somehow, but there’s no field in the metadata record that seems to be for that purpose.
Thanks! Once I solve this, I’ll write up a blog to use this tool to redirect to the child record from the standard New record UI. I hope! 🙂
January 9, 2019 at 8:19 pm
Ok let me take a look at this, will get back to you soon.
January 20, 2019 at 11:19 pm
This has been fixed in v2.5. https://github.com/afawcett/flowtoolbelt#packages. Also in this release, you do not need any special consideration for auto-launched flows, so do not worry about what the instructions say in respect to this. I will update the instructions to remove this reference.
January 20, 2019 at 11:16 pm
This has been fixed in v2.5. https://github.com/afawcett/flowtoolbelt#packages
Pingback: Dynamic Flow component – Deepthi Thati
Pingback: Tools | Andy in the Cloud – Kay Scott's Blog
May 23, 2019 at 7:48 pm
Hi Andrew– Thanks for that fix– custom objects are now working w/ the _custom in the custom metadata record name!
I am finally coming back to this… with some questions. Our business case is to navigate to a Child record after creating it from the Parent screen.
My end goal is to autolaunch the flow after creating a child record with an action. I’m using a Process, not an action, to launch the flow. I have a feeling I am taking it out of its comfort zone (or making a dumb mistake!) because it isn’t currently working.
This is not a Summer 19 sandbox. Here are the pieces I have set up:
~Action which creates a child Invoice__c from parent Contract. (I don’t want to use the Utility bar & a visual flow there because an admin has to maintain the fields over time and flow is a bit much for them. Action layout is easy).
~A process which fires on the creation of an Invoice. All it does is fire the flow I set up for Dynamic Flow Component. It passes in the ID of the Invoice just created to the flow
~ A Flow which:
1. Finds the Invoice record via the passed in ID, assigns it to an sObject variable
2. Calls the event navigateToSObject and passes in the parameter of the ID of the Invoice from that SO variable
*A debug of this flow shows that the right IDs all end up where they should, including the event navigateTo parameter.
~Custom metadata record for Contract (the parent– took me a while to realize even when autolaunching i should build this off the parent not Invoice). This is marked as an autolaunch flow.
*The only part I can’t tell if I need is the “Autolaunched output variables”-I don’t see that in docs and it looks like you retired it maybe? I had to pull the is autolaunch & that field back in to layout because the instructions seem to indicate you needed it back when I first started this. I’ve tried putting my one new variable, the invoice record sobject variable in there, but it doens’t seem to make a difference
~Deployed the class & test class on the Flow Factory tab (removed and redeployed after making changes even, but doesn’t look from the class like taht would matter)
It’s not redirecting. I looked at a debug log. It runs the action, then the process, then the flow, but the DFC is never called.
Any ideas? Can it just not be fired in such a way where you are firing the flow via a Process? THANKS!
June 15, 2019 at 4:42 pm
No worries. Does this video help https://www.youtube.com/watch?v=yY537m6X6Ok ? Sorry for the late reply btw. Andy.
June 20, 2019 at 11:26 am
Hi- Thanks, I had seen that. The issue is that we aren’t using a visual flow in the utility bar (or elsewhere on the page); we are trying to navigate to the child after creating it with an action. It works great in the utility bar/flow scenario, but this is a low level admin who would find updating the flow to adjust fields & default values challenging over time. I wanted to give her an action instead.
Action creates child record
Process calls the Flow that is set up like yours, except the variables are coming from the process
Flow is supposed to redirect, doesn’t
July 4, 2019 at 10:35 am
So unless the flow is used within this component those redirect variables will do nothing I am afraid.
October 22, 2019 at 10:14 am
I’m trying to find a solution that will run a flow and then highlight / select Macros in the utility bar. It seems like that should be possible with this? I haven’t been able to get the utility bar highlight to work in the flow, which is likely an error on my end. However, can the utility functionality highlight the Macros utility item or will it only highlight the flow utility item?
December 28, 2019 at 7:19 pm
It just highlights itself. Though the utility bad api does expose all utilities. So it’s possible with an enhancement. Though this will just highlight it not a specific macro.
April 9, 2020 at 2:49 pm
I’m interesting in this feature: By setting the optional variable flowtb_flow to the name of a given Flow, the DFC will automatically run that flow when the current one completes. This allows you to dynamically control which screen Flow to run based on record details
I added your flow component to the lightning record page, that launches an autolaunch flow that looks at the record details. IF the opportunity is in a certain stage I want a screen flow to run. However, I cannot figure out how to link the autolaunch flow to the screenflow (I can’t use the subflow element).
if I use your component to launch the screenflow, then the screen only shows up in that portion of the lightning record page and I want the screen to be the entire page.
Is that possible?
April 12, 2020 at 5:37 pm
In your auto launch flow define an output variable as defined in the vlog flowtb_flow and set it