+ Start a Discussion
Priyanshi AggarwalPriyanshi Aggarwal 

How to access Multiselect Picklist Values individually in Flows ?

Hi All,

I need to access the individual value of a multiselect picklist field in my flow and compare each value to a text field in another object.
 While doing so, all the values of multiselect picklist are coming in the format "HR;Sales;Finance" but I have to access them individually.
Can any one help me out in this. 

Thanks In Advance!
Jerun JoseJerun Jose

Multiselect picklist fields are stored as text values in the database. There is no easy way of getting these values returned in an array or list fashion.

However, can you not just use the CONTAINS function to check if the text value is present in the picklist value?

Priyanshi AggarwalPriyanshi Aggarwal
Hi Jerus,
Thanks for replying.
I tried the CONTAINS function and it has worked to a large extent . But this can cause problem for the fields value which are similar like Sales and Presales . It will consider sales and presales equal.   
Is there any other way for doing this ?
Jerun JoseJerun Jose
No simple way I'm afraid. One possibility would be to check seperately for the 3 places the value might be: beginning, middle and the end and useing the semicolon delimiter as well in your check

Something like 
pickField.equals(myStr) OR pickField.begins(myStr+";") OR pickField.contains(";"+myStr+";") OR pickfield.endsWith(";"+myStr)

I know I wrote the crude operations above but you should be able to build a complex formula that can do this for you. Please let me know if were able to achieve this and post the formula once done so that others can benefit.
N.M. SharmaN.M. Sharma
Hi Priyanshi,

Try this:
string st = 'HR;Sales;Finance';
list<string> strLst = st.split(';');
set<string> strSet =  new set<string>(strLst);
system.debug('str: ' + strSet.contains('Finance'));

By using contains you easily check your values.
Priyanshi AggarwalPriyanshi Aggarwal
Jerun and N.M.

This is possible with Coding. But I have a big scenerio which I am doing using Flows. These multiselect picklist values are needed in that. 
So, I was looking for a solution in Flows. If no solution is found, then I will use coding.


Jerun JoseJerun Jose
Hi Priyanshi, I was not suggesting to use code. I had simply mentioned what the end result should look like. You can write a formula which does exactly the same thing. There are built in functions to check if the string begins with or contains a search string. Checking if the string ends with the search string might be a little tougher though. Anyway, what I'm saying is there are configurable ways to get this done. Either create a formula field which will do this check for you, or create a sub flow with multiple branches to check the different conditions and then derive the net output. Lastly, you could even build an apex plug-in that you can call from your flow, so just because you use apex doesn't mean you cannot use flows.
Priyanshi AggarwalPriyanshi Aggarwal
Hi Jerun and N.M
I created an invocable method in my Apex class to split my multiselect picklist value into List of Strings which I am calling in my Flow. But the problem which I am facing is the output field while using the apex class in Flow. The Apex class is returning a List of String Data Type but while assigning output to a collection variable , validation prevents collection variable assignment. 
My Apex Class is 
global class ParseMultiSelect
    list<String> ls;
    public static List<String> ParseMultiSelect(List<Company__c> c)
        list<String> ls= new list<String>();
        for(Company__c ss: c)
            String a=String.ValueOf(ss.Programme__c);
        return ls;
And the error that I am gettting is 

User-added image

Can you help me out in this?