Display a Picklist of Flow Names with the FlowList Control

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.

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:

Supported attributes

label – field label;

selectedFlowApiName – if flow is selected, its api name is recorded in this variable, also component can be initialized if value is passed from parent component;

showActiveFlowsOnly(default=false) – if true, shows only active flow components;

required(default=false) – if true, field becomes required and component will throw an error on attempt to navigate to next flow screen;

showWhichFlowTypes(default='Flow,AutolaunchedFlow') – specifies flow types;

Developer Notes

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:

  1. Use its Apex controller to make an SObject query to get the list of flows
  2. 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:

Component javascript 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.

Old Versions

1 reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply