Ask Search:
Bill DavisBill Davis 

Update Multi-Select Picklist Value using Flow

We have a Multi-Select Picklist (MSP) field that that contains a handful of values for our users to select. 
We also have a custom object that can select a contact to add to that object and when that happens we want to update a MSP that exists on the contact.
We have realized that the MSP values can be updated using flow and we have a flow that we are testing to resolve this.  I am struggling with the concept of grabbing the existing values in the MSP and adding a new value (Billing Contact) to the MSP if that value is not selected.

Scenario:
- Contact is added to custom object
- MSP contains two existing values and we need to add a new value to the list
- We leverage process builder to identify the contact that is being added to the custom object and then can use that ID in the flows to update MSP

Where I am struggling is how to set the variables in the flow to allow us to see the existing and add the new.

This is my first day using flows and trying to resolve this issue in the near future.
Best Answer chosen by Bill Davis
Narender SinghNarender Singh
Hi Bill,

First what you will need to do is store the MSP field value in a text variable in your flow. You can either pass the MSP value via process builder or you can do a record lookup to get the MSP field valuea and store it in a value.

Now suppose you have A and B values in MSP, then the text variable will look like:
[A;B]
And let's say you want to add 'C' to this.

So in order to do that you will need to create a formula like this:
SUBSTITUTE(
SUBSTITUTE({!MultiPicklistValues}, '[' , ''),
']',
';C')
So what's happening here is we are first removing '[' and then substituting ']' with ';C', because MSP values are seperated by ';'

Now simply assign this formula to the MSP field in your record lookup.

All Answers

Narender SinghNarender Singh
Hi Bill,

First what you will need to do is store the MSP field value in a text variable in your flow. You can either pass the MSP value via process builder or you can do a record lookup to get the MSP field valuea and store it in a value.

Now suppose you have A and B values in MSP, then the text variable will look like:
[A;B]
And let's say you want to add 'C' to this.

So in order to do that you will need to create a formula like this:
SUBSTITUTE(
SUBSTITUTE({!MultiPicklistValues}, '[' , ''),
']',
';C')
So what's happening here is we are first removing '[' and then substituting ']' with ';C', because MSP values are seperated by ';'

Now simply assign this formula to the MSP field in your record lookup.
This was selected as the best answer
Bill DavisBill Davis
That makes sense, but how do you exclude the value if it already exists? For example, if A & C exist on as MSP and we want to only add C when C does not exist. If we do that you have here, we create an identical C value in the MSP.
Narender SinghNarender Singh
Since it is stored as text variable in the flow, so you can use CONTAINS function. 
Something like this:
CONTAINS(MSP__c,"C")
It will return true or false accordingly.
 
Bill DavisBill Davis
Thanks Narender, when setting this up today with the following Formula: SUBSTITUTE( SUBSTITUTE({!CaptureExistingContactRoles}, '[' , ''), ']', ';Billing/Invoicing (Accounts Payable)') I get the following error message [cid:image001.jpg@01D48C6F.FA2BCCE0] Any ideas on how to proceed?
Bill DavisBill Davis
Sorry, here is the image
User-added image
Narender SinghNarender Singh
You cannot directly reference a MSP like that in a formula.

Use an Assignment block to assign the value of MSP to a text variable. Now use that text variable in the formula, and then use the formula to update the value to MSP.
Bill DavisBill Davis
Thanks Narender, this was all very helpful in my learning of how the Flows work and applying it to our scenario.