+ Start a Discussion
rahul reddy 21rahul reddy 21 

Can any one help me how to query multi-select picklist values to filter the records on click of search button

I have a picklist field on account object,using search button I am able to filter the records by selecting a picklist value.
but now i want to use the same picklist value as multi-select  picklist. 
can any one help me in resolving the issue.

Vf code:
<apex:page controller="ACCsearch">
  <apex:form id="form">  
        <apex:inputText value="{!searchstring}" label="Input"/>        
        <apex:selectList value="{!Typeoptions}" label="Type" size="2" multiselect="true" >
            <apex:selectOptions value="{!selectedType}"></apex:selectOptions>
            <apex:commandButton value="Searchrecords" action="{!search1}"/>
                <apex:pageBlock title="Inst Records" id="Block1">
                <apex:pageBlockSection id="section" collapsible="true" title="TABS">                
                    <apex:pageBlockTable value="{!Instlist}" var="inst" >
                        <apex:column value="{!inst.Name}"/>                                            
                        <apex:column value="{!inst.Type}"/>        

apex code:
public class ACCsearch
    public list<Account> Instlist{get;set;}
    public string searchstring{get;set;}
    public string Typeoptions{get;set;}
    public ACCsearch()
        string strqry ='select Name,Type  from Account';
    public list<Selectoption> GetselectedType()
       List<SelectOption> options = new List<SelectOption>();           
       Schema.DescribeFieldResult fieldResult =Account.Type.getDescribe();
       List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();           
       options.add(new SelectOption('None','--None--'));
       for( Schema.PicklistEntry f : ple)
          options.add(new SelectOption(f.getLabel(), f.getValue()));
           return options;
     public void search1()
        string strqry ='select id,Name, Active__c,Type from Account where id !=null ';
           strqry =strqry +'and Type LIKE \'%'+Typeoptions+'%\'';
           strqry =strqry +'and Name LIKE \'%'+searchstring+'%\'';
Check this:


Bharathimohan Ramamurthy
Salesforce For All (http://salesforceforall.blogspot.com/)
rahul reddy 21rahul reddy 21
HI Bharathimohan

I tried that senario earlier,in the debug log I found error message stating cannot use INCLUDE for field which is of the datatype-picklist.That senario works for multipicklist datatype.I am in need of query for picklist datatype which can be use to select multiple values from the dropdown.