Parsing An Object’s Multi-Select Picklist Selection/(s) To Use In A Visual Flow

You are currently viewing Parsing An Object’s Multi-Select Picklist Selection/(s) To Use In A Visual Flow

I recently worked on an interesting requirement which demanded grabbing the Multi-Select Picklist selection/(s) from an object’s field and then showing them in a picklist as select-able options on a Flow screen. So this is what the user flow looks like:

  • User makes selections on an Multi-Select Picklist on the main object.
  • User then clicks a custom button on this object which takes him through a Visual Flow.
  • Within this Flow, the User is shown a screen with another picklist (single select or multi select).
  • This picklist shows values from the Multi-Select Picklist selections chosen in the first step. Which means it has to a Dynamic Record Choice as its source.
  • Further logic is executed based on the picklist item selected.

The parsing idea was suggested by an active success community member David Litton (thanks!) and that was enough to get me started. Here is the what the final flow looks like:

 

Flow Designer
Flow Designer

 

Let’s go through the elements one by one and how we utilized them:

  1. Record Lookup
    We are launching our flow using a custom button on our Test Object so a record lookup element is used to find the record and store our Multi-Select Picklist selection/(s) in a text variable. Now we could have passed the MSP value directly via the button URL but I had to store a lot of other record values as a part of the original requirement hence the Record Lookup element.RL
    Objective: We store our raw unparsed Multi-Select Picklist selection/(s) in a text variable. In case you are curious, this is what it looks like:Sel1Sel2
  2. Assignment (Remove Square Brackets)
    Towards our first step in parsing the values, let’s get rid of the square brackets. Once the square brackets are removed, we assign the values to another variable.Ass1

    Bracketless
    The above formula removes the square brackets and adds a semi colon (;) at the end of the string. The semi colon would be our delimiter aid for the parsing.
  3. Decision
    We will be extracting the needed SuperHero from our {!vSelectedSuperHeroes} variable one by one and continue doing this until there’s nothing left in it. An empty  {!vSelectedSuperHeroes} variable means all super heroes have been extracted from the source string and we can proceed with the rest of the logic in the Flow.Decision
  4. Assignment (Add to Usable Collection)
    This element is our first step towards forming our collection of Parsed Super Heroes. What we do here is that take out a Super Hero from the {!vSelectedSuperHeroes} variable and then assign it to a string collection Flow variable {!vParsedHeroesCollection}.Ass2
  5. Assignment (Remove from Original Collection)
    In this step, we remove the {!OneSuperHero} + “;”  string from the  {!vSelectedSuperHeroes} variable and move towards emptying it out.Ass3The {!RemoveFirstPG} formula field is what we use to remove the superhero one at a time from the {!vSelectedSuperHeroes} variable.Form
  6. Loop (through the Parsed Heroes Collection)
    We now loop through our Parsed Heroes Collection variable in order to create a Custom Setting record for each Super Hero selection.Lop
  7. Record Create (Create Custom Setting Records)
    For each parsed value, we create a custom setting record.CustomThis is what our final outcome looks like:SHAnd we are done! Now why did we put the parsed values into a Custom Setting? Well we might need to use the selected Super Heroes from our Multi-Select Picklist to create the items for a Picklist on a Flow screen which must use a Dynamic Record Choice as the source. Creating custom setting records helps us easily achieve that. You could always do a Fast Delete at the end of the full flow to remove the custom setting records once their purpose is served.

 

Wasn’t that easy? I can already think of a ton of ways to use this for other related implementations and hope that so do you. I know that there might be better ways to do this or even optimize what I did and will continue improving this logic if I can think of something creative. If you designed such a logic in flow using other methods, I would love to hear about it in the comments below.