Flow Multi-Select Picklist Selection Workaround

Recently, a colleague ran into the Flow Multi-Select Limitation¬†where only the last option selected in a multi-select picklist input was being used later in the flow despite all the values being selected and being semi-colon space “; ” delimited. To work around this, a sub-flow was used to take in the semi-colon space delimited values, parse out the values, and output a text collection¬†of the picklist values.

Summary Description

The above sub-flow does the following:

  1. Takes in a semi-colon space separated list of multi-select picklist values in a variable.
  2. If the variable has one or more values, fetch the next picklist value from the variable, add it to a text collection and remove it from the variable.
  3. If there are more values, repeat from step 2. Otherwise, stop and output the text collection.

Let’s take this step-by-step.

Create the mspValues Variable

First, create an mspValues Text, Input Only Variable so that the sub-flow can have the semi-colon space delimited values passed to it.

Next, let’s create the formula fields that will help parse out the values.

Create Next_Picklist_Value Formula

The Next_Picklist_Value formula parses out the next picklist value from the mspValues input, if there is one.

If (IsBlank({!mspValues}), null,
If (Contains({!mspValues}, ‘; ‘) == false, {!mspValues} ,
Left( {!mspValues} , Find(‘;’, {!mspValues} ) – 1)
))

This formula says

  1. If the mspValues is blank, return null.
  2. Otherwise if the mspValues doesn’t contain a semi-colon, return the variable because it only has one value left.
  3. Otherwise, there are multiple values so only return the first one by returning everything from the start of the variable up to, but excluding, the semi-colon.

Create Has More Picklist Values? Decision

Now, add a decision to the canvas and name it “Has More Picklist Values?”. The first editable outcome is “Has Picklist Value” and its criteria is “Next_Picklist_Values is Null $GlobalConstant.False”. Also, relabel the default outcome to “No More Picklist Values” so it’s more descriptive.

Please remember to occasionally save the flow so the work isn’t lost. At this point, our decision element determines if there are additional values or not so now we can add the picklist values to a text collection so let’s create the collection next.

Create the Picklist Values Collection

Now, let’s create the Picklist_Values_Collection so that the master flow that uses the sub-flow can use the parsed values.

Now that we have the text collection, let’s add the picklist values to it.

Create Add Picklist to Picklist Collection Assignment

Add an assignment to the canvas that adds the Next_Picklist_Value formula to the Picklist_Values_Collection text collection.

After the assignment is added, connect the “Has More Picklist Values?” decision to the assignment using the “Has Picklist Value” outcome. After the picklist value is added to the collection, it has to be removed from the mspValues variable so that it won’t be added again. Now we have to fetch the remaining values and update the mspValues variable with the remaining ones. We’ll do that by creating a new formula to calculate the remaining values and another assignment variable to update the mspValues variable with the remaining values.

Create Remaining_Picklist_Values Formula

If( contains( {!mspValues} , ‘;’) == false, null,
Right( {!mspValues} , Len( {!mspValues} ) – Find( ‘;’, {!mspValues} ) – 1))

This formula says

  1. If there’s no semi-colon in the mspValues variable, return null to signal there are no other values. Remember that even though the picklist has been added to the collection, it hasn’t been removed from the mspValues variable yet.
  2. Otherwise there is a semi-colon and there are more values so fetch the remaining values to the right of the semi-colon and space delimiter and return that.

With the Remaining_Picklist_Values formula created, now the second assignment can be created to update the mspValues variable to the remaining ones.

Create Remove First Picklist Value Assignment

Add a second assignment to the canvas and name it “Remove First Picklist Value”. Set the variable to “mspValues”, the operator to “equals”, and the value to “Remaining_Picklist_Values” formula.

Now, connect the “Add Picklist to Picklist Collection” assignment to the “Remove First Picklist Value” assignment.

Next, connect the “Remove First Picklist Value” assignment to the “Has More Picklist Values?” decision.

Save, Activate and use it in your other flows as needed. This is used immediately after your screen with the multi-select picklist input on it and it as the input to this sub-flow. The output of this sub-flow is the text collection to map to another text-collection that can then be used as needed.

For the coders reading this, we’re essentially creating a while loop in our flow that parses out the values from the semi-colon space “; ” separated list of mult-select picklist values passed into it and outputting the values in a text collection.

Leave a Reply

Your email address will not be published. Required fields are marked *