Fun with Salesforce Flows – Parsing Multi Select Picklist fields

Standard

Fun with Flows – Parsing Data

I recently ran into a challenge while making / scripting / conjuring a fairly complex flow. I needed to get data out of a Multi Select Picklist (MSP) field for use later on in my flow. The google hive brain did not help at all…literally, I couldn’t find anything when googling on terms such as “salesforce visual flow parse”. Once I started googling ““salesforce parse” I got lots of results…for apex solutions.

So once again, I find myself faced with the following:

1)      Check my “Clicks Not Code” membership at the door and start down the apex path?

2)      Write some crazy formula field to do this work and then pass data back and forth?

3)      Put on my thinking cap and figure out a way to get this done with in a flow?

And as usual, I opt for #3.

First things first, I had to figure out what I had to work with. To do this, I extracted some data from my MSP fields and found that MSP’s store their data in a very logical way, ((“Value””SemiColon”)). What this means to me is that when I run the query on the object and push MSP field data to a variable, it is going to ONLY bring over the data that has been selected and it was going to show up as a text string. I had a hunch that the MSP would act this, but you know what they say, “Trust but verify”. This behavior also reinforced why I wanted to parse the data. Carrying around a full string like “Value 1; Value 2; Value 3” really reduces what you can do within flows.

Now that I know what I am working with, I can go about getting the data into the format I want. The quick synopsis is that I am going to:

1)      Create variable for the MSP Values

2)      Create decisions for each MSP Value

3)      String the decisions together

For this example, I have the MSP field “McDuck” that contains the values Huey, Louie, Dewey, Donald, Daisey and Scrooge. I want to separate out any selection into their own variable for use in other parts of my flow. Here are the steps I am going to run through (Visual in the PDF).

1)      Query “GetData” passes the values in the field “McDuck” to “varGotMcDuckData”

Image

2)      The data in “varGotMcDuckData” is then ran through a number of decision setps.

     ParseHuey takes a look at “varGotMcDuckData” and if the data in that variable contains “Huey”, then populates “VarHuey” with “Huey”

Image

      ParseDewey takes a look at “varGotMcDuckData” and if the data in that variable contains “Dewey”, then populates “VarDewey” with “Dewey”

Image

3) Rinse, wash, repeat as needed!

There are a couple things important to keep in mind when doing this. The first is that these can get really big really quick. Don’t be afraid to use a subflow to do the dirty work (Future Topic!). Also keep in mind that once data gets passed into a variable, data is retained there until the flow stops. If you are going to have a multi-step process you need to build in a clean step where the variables are scrubbed of data.

Even though this is a fairly elaborate process, it really does go by quickly. The added benefit is that flows are recyclable, so if I ever had a need to parse out the McDucks in a flow anywhere, I could reference my parsing flows over and over and over again.

 

Andrew

Advertisement

16 thoughts on “Fun with Salesforce Flows – Parsing Multi Select Picklist fields

  1. Clint Majors

    Thanks for this post. I have facing the same issue. After I read your post I built a flow to be used as a sub-flow that separates each item chosen from any MSP and adds each item to a collection variable. If you’re interested in seeing how I did this let me and I’ll happily share what you helped me build!

    • Hey Clint!
      Thanks for letting me know that you found this post useful! I wrote this “Back in the good old days” before these newfangled loops / collections and such, so it is due for a refresh!

      If you are on the success community, look me up…I would love to see how you did this!

      andrew

  2. NCOMM

    Hi,

    I have the same probleme but my Picklist is based on a “Dynamic Choices” and I can’t know wich Data it will contain and then, cant build a Flow like you did… Don’t know how but I’ll have to find another way 🙂

    • Glad to hear the determination. Most of the stuff I have figured out here is the result of stepping back, looking at a problem and saying to myself “There has to be a better way”.

      If you can, get the data into a variable. Once it’s there, it’s there and you can use it however you would like!

      Andrew

      • NCOMM

        I did it and Your modus operandi for your case helped me!

        It’s not as simple and elegant as I would have liked but it works without a line of APEX code!

        The idea is :
        – load concerned Account in a Collection with a Fast Lookup
        – Put a multiple selection picklist in the form, based on dynamic Choices and using the same selection criterias than the FastLookup on Accounts (the result of “checked” Accounts in the form will be a String with selected IDs separated with “;”)
        – Loop on each Account of the Collection and check if the ID is contained in the Picklist selection, if yes, I create a record for this Account.

  3. john

    Hello,
    I was curious if this is still relevant given the introduction of loops and collection variables in flows. I have the following objective and am unsure how to approach!

    Based on multi-select checkbox selections, we’d like to send static emails to a group of people based on each selection.

    For example, the user will be presented with a screen with a multi-select checkbox field labeled, “Teams to Email”. The selections could be “Team A”, “Team B”, and “Team C”.

    Based on what teams the user checks will determine what teams receive the email alert. So if only “Team A” and “Team C” get selected, only those two groups will be emailed.

    • Hi John,
      Thanks for dropping by. I appreciate hearing all the great questions and feedback!

      So far, I haven’t found a more reliable way of parsing MSP data since loops and collections only grab data from existing records. That being said, you could so something sneaky like using a custom object to house your picklist values and then query that to determine your values.

      As for your scenario, that is a PERFECT example of (in my opinion) flows sweet spot…storyboarding processes! What you described is pretty might right on for the idea, try sketching it out on paper or a whiteboard.

      let me know if you have any further questions!

      andrew

  4. sharon

    I can’t wait to try this! I need to pass the results of a MSP to the body of an email via flow. Between serious URL hacking and flows, I have been able to avoid Apex thus far! Results pending….

  5. This is nice solution, and gave me a great framework to think through the problem. I ended up taking the solution a step further, so I wasn’t hard-coding the decisions.
    1. knowing that the MSP is separated by a semi-colon, I start with a decision to look for Semi-colons.
    2. if the variable (varMSP) contains no semi-colons, then that’s the only value.
    3. if varMSP has a semi-colon, then look for it’s position: (find(“;”,{!varMSP})
    4. isolate the first value in the varMSP with a left command
    left({!varMSP},({!fxPositionOfSemicolon}-1))
    5. do what you need with the value, then
    6. update the varMSP as follows
    a. how much is left in the string: {!len(varMSP)}-{!fxPositionOfSemicolon}
    b. Assign varMSP as: right({!varMSP },{!fxSelectFromRight})
    7. return to #1, and repeat.

    • Hi There!
      Thanks for dropping by and checking this out. I really should update this post, but it still gets quite a few hits and provides a good foundation for some really nice solutions.

      I like yours quite a bit and have done some similar actions myself. You can even do what you described in a sub flow that you could use over and over again!

      Thanks again for dropping by.

      Andrew

  6. Shawna

    Hi.

    So, we have a multi-select picklist of competitors names. I want to create an OpportunityCompetitor (standard child object of Opportunity).

    I would like to be able to do this without any hardcoding of our 81 competitors and not create dupes and delete any records if a name is taken out of the mpl.

    I can get the record to create, but I’m getting duplicates and just am at a loss. Any help would be greatly appreciated. 🙂

    • Hi Shawna,
      First off, thanks for the comment! I don’t post as much as I should, but comments like this make my day!

      Now, for the issue you described. I have done similar work in the past, but have used a new object to hold all the values as records and then use a dynamic MSP in the flow to pull in those records.

      Short version:
      New Object, “Competitors”
      –> Field “Competitor Name”
      –> Checkbox Field “Active” (for deactivating competitors…when YOU CRUSH THEM WITH YOUR SALESFORCE AWESOMENESS!)

      With in the flow:
      –> New dynamic MSP
      –> Use the object “Competitor”
      –> filter for active

      The benefit to doing things this way are that you can let someone else maintain the list with out having to dig through the flow each time. Parsing is done the same way:-)

      andrew

      • Shawna

        Hi. Thank you so much for getting back to me. I’m starting to de-stress already!

        It seems like I am on the right path. I created a new object that contained the name of competitor and a checkbox.

        QQ: When you say New Dynamic MSP, are you talking about using the Resource Dynamic Record Choice. I’ve tried using that but didn’t quite understand it. Is that where the list would be maintained?

        Again. Thank you very much.

      • Hey – No problem! We all go through this stuff! Glad to help out!

        We are pretty much speaking the same language. Dynamic choice can be either a check box, MSP or Single Value Picklist. I will be honest, it takes some finagling (score, used finagling in everyday talk!) to get used to, but the principle is that your user will pick a value based on a label…you want to store something unique like the record ID of the actual record.

        I would HIGHLY suggest having a debug screen right after the dynamic MSP with a display text that shows the value from the dynamic record choice field. This way, you will see what is happening.

        Enjoy!

        andrew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s