Parsing Dynamic choice Multi-Select Picklist fields (Flow) – Reusable component

Parsing Dynamic choice Multi-Select Picklist fields (Flow) – Reusable component

Last Updated on April 15, 2019 by Rakesh Gupta

In the last article Add Record to Multiple Chatter Groups – Parsing Multi-Select Picklist fields (Flow) I had discussed the way through which you can Parse Multi-select picklist or Multi-select check-boxes and store Parsed Ids into a collection variable. In this article, I am going to give you a reusable component (Flow) that you can use to Parse Multi-select picklist or Multi-select check-boxes. You have to install this component (Package) in your org, after installation you can use it.

Business Use case

Tamara McCleary is working in Universal Container as a system administrator. After user creation, she has to spend few hours to add the user to multiple Public groups. Now she is looking for an application that allows her to add new users to multiple Public Groups without moving to screen-to-screen.

Steps to Install this app

I am offering this app as Managed package, you can install it from below URL

https://login.salesforce.com/packaging/installPackage.apexp?p0=04tB00000001Al4

To install this app replace Login with your Salesforce instance name in my case this url will look like

https://gs0.salesforce.com/packaging/installPackage.apexp?p0=04tB00000001Al4

Note :- For Mismatching Versions error please refer this thread. I have successfully installed this package into multiple org those are upgraded to Spring’15, as I have created it from Spring’15 pre-release org.

How to use this package as Sub-flow

Once you have successful  installed this package in your org, after that you can use it as sub-flow. To use this app It’s required one Input fields to pass SCREEN MULTI_SELECT FIELDS into Subflow variable {!SelectedIDs}, as shown in the following screenshot

Input Field
Input Field

One Output fields to reference Subflow Collection variable {!All_Selected_IDS} to flow collection variable, as shown in the following screenshot

Output Field
Output Field

Solution for the above business requirement

To solve this requirement we will use Visual Workflow, and then we will embed Flow to a custom link. Before proceeding you have to understand Group and GroupMember objects in Salesforce.

  1. Group :- This Group object represents Queue and Public Group both. Groups are sets of users.  A Group can contain individual users, other groups, the users in a particular role. By using Type field you can distinguish between Queue and Public Group. For Public Group (Use Type = Regular) and for Queue (Use Type = Queue).
  2. GroupMember :- Represents a User or Group that is a member of a public group.

Note:- In this article I will only discuss about adding user into Public groups . In similar fashion you can develop a flow for the Queue.

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
2. Click on New Flow, it will open flow canvas for you. Create One Text variable UserID (To pass the User ID from custom URL – to whom you wants to add into multiple Public Groups). Next step is  allowing users to select multiple Public Groups. To do that drag-and-drop a Screen Element ( Give the name Select Public Groups) onto the window and add a Dynamic choice Multi-Select check-box field with below detail

Name Data Type Required
Public Groups Multi-Select Checkbox Yes

It will look like the below screenshot

Dynamic choice Multi-select checkbox
Dynamic choice Multi-select checkbox

3. Create a collection variable {!All_IDs_In_One} as shown in the flowing screenshot to store the parsed IDs

Collection Variable
Collection Variable

4. Next step is to parse Multi-select check-box values into a collection variable. To do this drag-and-drop Flow MSP to Collection Variable onto the window and map Input/Output Variables assignment. Please refer to the following screenshot for more details

Input and Output Variables assignment
Input and Output Variables assignment

5. Drag and drop a Loop Element (Give the name Extract ID one by one) on the window and extract IDs from Collection variable and pass it to Text variable, as shown in the following screenshot

Extract IDs from Collection variable
Extract IDs from Collection variable

6. Drag and Drop Assignment Element (Give the name Assign Data into SObject Variable) on the window and assign value of {!SingleID} and {!UserID} to Sobject variable {!Group_Record} (GroupMember Object Type) ,as shown in the following screenshot

Add details into SObject Variable
Add details into SObject Variable

7. Drag-and-drop Assignment Element (Give the name All in one) on the window and assign value from Sobject variable {!Group_Record} to Sobject Collection variable {!All} (GroupMember Object Type) so at the end of the flow will use it inside the Fast Create to add user to Public Groups. Please refer to the following screenshot for more details

Add SObject Variables into a SObject Collection
Add SObject Variables into a SObject Collection

8. Finally drag-and-drop Fast Create (Give the name Add user to Public Groups) on the window and map the field according to the below screenshot

Add user to Public Groups
Add user to Public Groups

9. Finally our Flow will look like the following screenshot

Add user to Public Groups

10. Save the flow with name Add User to multiple Group and close the canvas.

Call a Flow from a Custom link 

We can call a Flow from custom button, link, sub-flow, Visualforce page , Apex start() or using Process builder. Here we will use custom link on User object to call our flow. To do that follow below instruction

1) Click on Setup | Build | Customize | Users | Custom Links
2) Click on New Button or Link button and construct a custom URL, as shown in the following screenshot

Custom Link
Custom Link

3) Add custom link into the User Page Layouts.

It’s time to test this feature

To test this flow, follow the below instructions

1) Create a New user, I have created a user with name “Demo user
2) Then click on custom link “Add user to multiple Groups“, available on the user detail page
3) It will open the flow for you. Select few public groups and click on the Next button, as shown in the following screenshot

Selected Public Groups
Selected Public Groups

4) Navigate to the Group related list available on detail page and you can see user is added to all of the selected groups.

Final Output
Final Output

Note :- I will suggest you to Implement this first on your developer org test it and then move it to Production.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

12 thoughts on “Parsing Dynamic choice Multi-Select Picklist fields (Flow) – Reusable component

  1. Rakesh,
    I’ve tried a variation of this where I am creating new records rather than doing what you are suggesting here. When I create the records, it seems as thought I am limited to naming the records with just 18 characters, and then if more, the characters are pushed into the next record and created there.

    Basically, I have a custom metadata type, which I am using to create the choices. From the selected choices, I wish to create a record which is associated to the record from which the flow is running from (In Lightning). I can’t access your flow to modify. Can you advise?

  2. Dear Rakesh,

    Thank you so much for taking the time to post this, it works perfectly and really just saved me a lot of frustration.

    Thank you so much! I really appreciate it!

    The next time you’re in Berlin, come to the SF Dev group for a beer (or maybe two!). 🙂

    Alex

  3. Hi. Is there a way to put this into my sandbox. I tried updating the id to my dev OrgID but it just updated what I had in my production. Tried a change set, but that didn’t work either. 🙂

      1. Thank you. I will give this a try and let you know how it turns out.

        Shawna R. Brooks
        Sales Support Manager/SFDC Administrator
        Merkle Inc.

      1. I’ve got your plugin working properly but now I’m struggling with the multi-select choice values being retained as I pass through a loop. Is there a way to clear the values so that the checkboxes don’t show up checked off the next time through the loop?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.