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
bensondanielbensondaniel 

Multiselect Picklist

Can anyone help me with Itereating through a multiselect picklist?

I need to make a list of all entries using a for loop.

KunisettyKunisetty

I am not sure what is your actual requirement, but hope this helps!

 

Test is a custom object and PickListMulti is a custom field on it.

 

trigger tstObject_beforeUpd on Test__c (before update) {

    for (Test__c t : trigger.new)   
    {

         String[] plmVal;  
         plmVal = t.PickListMulti__c.split(';');
  
         for(String strg: plmVal)
         {
                System.debug('-------------------------------------------->' + strg + '#');  
         }     

    }

}

super developersuper developer

Can You Please explain what do you want?

 

Do you want this vf pages.

Pradeep_NavatarPradeep_Navatar

Find below a sample code to get multiselect picklist values iterate through for loop.

 

 

VF Code:

           <apex:SelectList title="issue1" value="{!SkilVal}" multiselect="true">

                 <apex:selectOptions value="{!Skill}"/>                               

           </apex:selectList>

 

Controller Code:

                                   public String[] skilVal = new String[]{};

                                   public String[] getSkilVal()

                                   {

                                                                return skilVal;

                                   }

                                                public void setSkilVal(String[] skilVal)

                                                {

                                                                this.skilVal = skilVal;

                                                }

                                                if(skilVal.size() > 0)

                                                {

                                                                for(Integer i=0; i<skilVal.size(); i++)

                                                                {

                                                                                if (i == 0)

                                                                                {

                                                                                                strskil = skilVal[i];

                                                                                }

                                                                                else

                                                                                {

                                                                                                strskil = strskil + ';' + skilVal[i];

                                                                                }

                                                                }

                                                                System.debug('------  Picklist values --------'  + strskil);

                                                }