function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CyclebiffCyclebiff 

How are multi-select picklist data stored?

I have a custom multi-select picklist that I'd like to concatenate into a string, delimited by commas.
I'd like to do this through APEX -- any quick and dirty suggestions?

 

Or at least how is the data stored?

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

They are returned as a semi-colon delimited list of values (i.e. "Value 1;Value 2;Value 4"). You should be able to change the values to commas using:

MyMultiSelectField__c.replaceAll(';',',');

All Answers

sfdcfoxsfdcfox

They are returned as a semi-colon delimited list of values (i.e. "Value 1;Value 2;Value 4"). You should be able to change the values to commas using:

MyMultiSelectField__c.replaceAll(';',',');

This was selected as the best answer
CyclebiffCyclebiff
Thanks! This works!
shaanRocksshaanRocks
How can i pass values form a string to multipicklist field. I need to update a multipicklist field. I have concatenated a list of values to a string as: string str = '1; 2; 3; 4'; I thought of passing these values directly to the field but the field is not being updated. Please let me know what needs to be done.
sfdcfoxsfdcfox

If you're doing some type of "form post", you must use the HTML standard method of:

 

 

fieldname=value1&fieldname=value2&fieldname=value3...

If you're using Apex or the API, then you would use the semi-colon notation.

 

shaanRocksshaanRocks

Hi,

 

How to pass value of a string to a multi picklist field of an object using apex code.

 

I have a value stored in a string as:

string str =

004 - Florida;008 - Ohio River;013 - Carolinas;015 - Texas;024 - Gulf Coast;024 - Gulf Coast;030 - Empire State;040 - Sun Coast;032 - Pacific Northw;029 - Rocky Mountain
sfdcfoxsfdcfox

In Apex Code, you would just assign the string to the multiselect variable using the notation you posted. When you save the record, it will be stored as multiple values in the multiselect picklist.

shaanRocksshaanRocks

Hi SFDCFOX,

Thanks for your reply. The issue was with my code.

Now its working fine can pass directly a string to multipicklist.

 

Thanks again!

SFDC 1904SFDC 1904
How do we store data in database for multi select picklist from lightning component ?