THIS IS A SUMMER ’19 FEATURE. It will not work in Spring ’19 orgs.
FlowListFSC is a specialized combo box that you can drop into any flow screen. It displays a list of all of your flows, and can be configured to show just the active ones.
- View Source
- Install (unmanaged)
- Install (managed) — use this if you’re running into installation problems with unmanaged
I built FlowCombo because I’ve been exploring orchestration of multiple flows to solve more advanced business problems. In this prototype I’ve been working on, each of the blue buttons represents a flow that is associated with the current Case status. Click on the button and the flow runs:
In order for this to be useful, it needs to be possible for admins to customize these ‘Case Plans’ to meet their own needs. This is done with a flow called Case Plan Manager, that includes this screen:
When designing the UI above, I was able to use picklists for a couple of the fields, but I didn’t have an easy way to show a list of flows, because flows are metadata, and not records.
To solve this, I’ve built a custom component that is based on the standard lightning combo box. When it initializes, it does an Apex query using the newly available FlowDefinitionView SObject. This did not get put into the release notes, except in a mention here, so it’s a little under the radar. I’ll post more on it later.
FlowListFSC takes the following inputs:
Selected Flow ApiName is the name that has been selected by the user. When creating a new flow, putting it here in the input as well as the output causes it to be properly reloaded if the user clicks Previous from later in the flow.
Show Only Active Flows is self-explanatory.
The cmp file for my component passes an object called comboBoxOptionObject. It’s the job of the Apex controller FlowListController to take advantage of a brand-new Summer ’19 api for getting flow information.
The component has to carry out two key pieces of work:
- Use its Apex controller to make an SObject query to get the list of flows
- Transform the list of flows into the format expected by the base comboBox control.
At initialization time, the component quickly calls the associated apex controller:
Here’s the Apex controller. As you can see, all it really does is make a SOQL query and return the results. It also implements the Visualforce ‘special technique’ that’s used to get a SessionId:
The helper code does the work of converting the array of objects that comes back from Apex into the form expected by the combobox base control:
Finally, the component markup invokes the base control and defines the attributes:
And that’s it. Note that there are two other new resources, FlowVersionView and FlowVariableView, which let you drill down for details on a particular Flow or Flow Resource.