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

Multi-select picklist: displaying selected items

Hi, I have a question about the use of a multi-select picklist on a VF page. I have a custom multi-select picklist on an Opportunity and what I need to do is display all the selected items from that picklist on a VF page and have them look something like this:


"Item 1, Item 2, Item 3...." or "N/A" if none are selected.


How would I do that? The only function I found that deals with multiselect picklists is INCLUDES and I have a lot of items in the picklist so it would be a pain to do it through if... then statments. Thanks in advance!


something like this ok?

<apex:outputField value="{!yourObject.yourFieldname__c}"/>


If that's not good enough, I think you have to define a list variable of type string and set it to the field value. Then you can iterate over the list and concatenate the values to a string of your choice.


something like 

list<string> theList = new List<string>();
theList = yourObject.yourFieldname__c;

String displayString = '';
for (string aString:theList)
  displayString += aString + ', ';