Updating a Multi-select Picklist in a Screen Flow

Josh Dayment
5 min readDec 22, 2020

I know I said a curse word many Salesforce Admins like myself have learned from the many greats who have come before us do not use a Multi-select Picklist even saying that phrase is a curse word. One of the reasons is it can be difficult to update the values in a MSP using an automation tool i.e. Process Builder, Workflow Rule, or Flow. It is easy to add to but not take away. There is a native MSP Screen Component in Flow however it is ugly and a little confusing to use for most end users as well as can be confusing setting the already selected values from the record. We will start this series with a screen flow and in another article I will cover how to do this with an autolaunched flow. In my org we have 1 MSP that has survived the test of time just because it was one of those things that was available when we first became Salesforce customers and is now part of several marketing reports and sales reports and it's hard to get away from. I recently had a need to quickly and effectively add to or remove specific values from that field so I don’t like to think there isn’t anything I can’t do in Salesforce using flow with the mantra of clicks not code.

Let’s Get started. For reference throughout this flow we are using the Contact Object and a custom field that is a MSP on the Contact called Tags__c we use this as a marketing segmentation field.

Step 1: Get our contact use a get element to get the contact record that you wish to update and evaluate existing field data on.

Step 2: I have a decision as my Step 2 because I am going to use an apex action in step 3 to convert my existing values on my Tags field to a collection (you will see why later on) So my decision decides if there is currently a value in my Tags field if there is a we will us an apex action to convert that value to a collection if not it will move on to Step 4.

Step 3: I am using an apex action called “Convert any String to String Collection” this is part of the list actions for flow package from unofficialsf. I am using this to take my existing MSP values and convert them to a string collection to use later on in my flow. This action uses a delimiter to “break up the values” in this case an MSP value is delimited by a ; so that is my delimiter.

Step 4: In this step I am using another apex action to grab the available choices from my MSP Tags that I have on the contact object this action is called GetPicklistValues and is part of the same package in Step 3 you give it a field name and what object you are getting those values from. I am storing these in a text collection.

Step 5: This step is where I am presenting the options and current values to the user to update. To do this I am using the Dual List Box LWC from unofficialsf.com which is part of the Flow Screen Components Base Package. (This is also available as a standalone component but I recommend installing the whole package) Inputs that are important are Values that I get from Step 4 my collection of Tag Options. Selected Values I get from Step 3 my TagCollectionText. Note: I am experiencing a bug where I have to manually store the output variable on the component so this gets saved in a single CSV string (comma separated variable)

This is what the component translates to

Step 6: I am taking the CSV of selected “Tags” from the DualListBox my variable is named SelectedTagsCSV and am converting to a collection I can loop through. To do this I am using an apex action called Convert Comma-separated-values to String Collection this is part of the package mentioned earlier.

Step 7: Take a break we are almost there!

Step 8: Here I am doing a loop and an assignment (just because my mentor always tells me you know a flow is good when there is a loop 😁) I am looping through the SelectedTags collection I just created and I am going to assign each Selected Tag to a new Mulit-Select Picklist Variable I named NewTags.

Step 9: Here I am updating the contact with the new values on the MSP field aka Tags in this flow.

Step 10: Put on a cape because you are now a super hero!

Step 11: Sit back enjoy your beverage of choice!

--

--