+ Start a Discussion
force shahidforce shahid 

How to do prefilling in multi select picklist field

 Hi friends,
When a page is loaded, I need multi-select picklist field should be prefilled with some value. Is it possible? 
Thanks in advance.

Thanks ,
Alain CabonAlain Cabon

If you use <apex:inputfield> and <apex:outputfield>, the saved values of the multi-select picklist are easily shown.

The prefilled values are separated by semicolons ( ; ).
public class TestPage {
    public TestAll__c ta {get;set;}
    public PageReference pageButton () {
        system.debug('test:' + ta.picklist_multi__c);
        return null;
    public TestPage() {
        ta = new TestAll__c();
        ta.picklist_multi__c = 'value1;value2;value5';  // prefilled values
<apex:page controller="TestPage" >
                <apex:commandButton value="test" action="{!pagebutton}" />   
            <apex:inputField id="test" value="{!ta.picklist_multi__c}" />