Create a Flow with a Multi-Select Picklist
Learning Objectives
In this badge, you'll:
- Build a screen flow that contains a multi-select picklist component.
- Create an Assignment element that stores the selections as a string in a text variable.
- Use a Decision element and the Connect to Element function to form a manual loop.
- Create formulas and Assignment elements that manage the selections and copy them to a text collection, one at a time.
- Transform the text collection's selections into a record collection variable.
Work with Multi-Select Choice Sets
In Flow Builder, you create a manual loop when you use the Connect to Element function to manually connect an element on a Decision’s path back to that Decision element, forming a looping path. The path doesn’t visually form a loop, but the Go To Connector that was created by the Connect to Element function points the flow’s path back to a previous element.

As stated in the Loops in Flow Builder badge, you should create a manual loop in a flow only when necessary. Unfortunately, the Checkbox Group, Choice Lookup, and Multi-select Picklist components, which work well with choice sets, are incompatible with Transform and Loop elements. When you use a Checkbox Group, Choice Lookup, or Multi-Select Picklist to capture multiple choices, you must process the chosen options by looping through them manually. But Loop elements can't loop through screen component selections, so how do you loop through those selections?
When working with multiple points of similar data, flows work best if that data is in one collection variable. However, those components store their data in a single text string that looks like this: 001B000000Qu2XxIAJ;001B000000Qu2XyIAJ;001B000000Qu2XzIAJ;001B000000Qu2Y0IAJ
The selections are stored as a text string of record IDs, separated by semicolons. Salesforce considers this kind of data to be unstructured data: a series of text values stored together with no system-controlled separation. The semicolons separating the IDs provide some structure, but these semicolons can be moved or removed, so Salesforce doesn’t recognize them as definitive structure.
In contrast, collection variables are structured data, made of individual values separated by the variable. This separation is important, because it tells the flow with absolute certainty where one value ends and the next value begins.
Certain elements’ configuration, such as the Get Records element, accept only structured data—a collection variable. So if you need to use choice set selections in one of these structured-data-only elements, you must convert the unstructured data into the structured data of a collection variable. Sometimes you just need to turn a semicolon-delimited string of IDs into a text collection variable, but other times, you might also need to turn that new text collection variable into a record collection variable.
Break a Long String of Values into Many Smaller Values
To process multiple selections from a choice set-based screen component, create a flow that:
- Gathers selections on a screen.
- Uses Assignment elements and formulas to copy the first selection into a text collection variable.
- Uses a Decision element and the Connect to Element function to loop back and do step 2 again, repeating as needed until all selections have been copied to the text collection variable.
- Uses a Get Records element to retrieve all the records whose IDs are in the text collection variable and store them in a record collection variable.
- Does whatever you need to do with that record collection variable.
There's a lot of magic buried in step 2, but don't worry, we'll break that step down further.
Create a New Trailhead Playground
For this hands-on badge, you need to create a new Trailhead Playground. Scroll to the bottom of this page, click the playground name, then click Create Playground. It typically takes 3–4 minutes to create a new Trailhead Playground.
Note: Yes, we really mean a brand-new Trailhead playground! If you use an existing org or playground, you can run into problems completing this badge.
Create a Screen Flow
In this badge, you help the marketing team at Pyroclastic, Inc. to create a flow. They want to add all of an account’s contacts to a campaign, and they want to do it for multiple accounts. Create a flow that runs from a campaign record page, asks users to select accounts, converts those selections into a text collection, retrieves all the contacts related to the chosen accounts, and adds them to the current campaign as campaign members.
- Create a screen flow.
- Create a variable to store the current campaign’s ID.
- For Resource Type, select Variable.
- For API Name, enter
varCampaignID.
- For Data Type, select Text.
- For Availability Outside the Flow, select Available for input.
- Click Done.
- For Resource Type, select Variable.
- Create a Screen element that asks the user to choose accounts.
- For Label, enter
Select Accounts.
- Make sure the API Name is
Select_Accounts.
- For Label, enter
- Add a Multi-Select Picklist component to the screen canvas.
- For Label, enter
Select accounts - all related contacts will be added to this campaign.
- Make sure the API Name is
Select_accounts_all_related_contacts_will_be_added_to_this_campaign.
- For Let Users Select Multiple Options, make sure Yes is selected.
- For Choice, select New Choice Resource.
- For Resource Type, select Record Choice Set.
- For API Name, enter
AccountChoice.
- For Object, select Account.
- For Condition Requirements, select None—Get All Account Records.
- For Sort Order, select Ascending.
- For Sort By, select Name.
- For Choice Label, select Name.
- For Choice Value, select Id.
- Click Done to close the New Choice Resource window.
- For Resource Type, select Record Choice Set.
- Click Done to close the screen canvas.
- For Label, enter
- Save the flow.
- For Flow Label, enter
Create Campaign Members from Selected Accounts.
- Make sure the Flow API Name is
Create_Campaign_Members_from_Selected_Accounts.
- For Flow Label, enter
