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
shaanRocksshaanRocks 

How to pass values to multipicklist field type

 

How to pass values to multipicklist field type using apex code.

Here is my Requirement:

 

I have  a Value stored in string now 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
dfiredfire

from my experience, a multi-select picklist is just a string field, that SFDC will parse when editing in the browser.

 

So if you have your str like you listed you just need to assign it to the field

 

myCustomMSPicklist__c = str;

Ankit AroraAnkit Arora

Hi Shaan,

 

When you save the record then values selected in multiselect picklist will get saved with delimiter ";" . When you want  to prefill the picklist with the saved values then just create a list of string e.g. (A,B) and directly bind it with your class property which is a selectlist.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page