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
mchandramchandra 

Unable to retrieve the values from the multi select picklist

I have multiselect field called technology type.When i select a value and click on a button all the accounts belong to that particular technology type Should be displayed.

Here's my code.

Page:
<apex:pageBlockSectionItem id="TechnoType">
              TechnologyType
        <apex:outputPanel id="multiSelectPanel" >
                <c:Multiselect leftLabel="Available" leftOptionsAttr="{!AvailableProductOptions}" rightLabel="Selected" rightOptionsAttr="{!selectedOptions}" size="5" width="200px" />
            </apex:outputPanel>
            </apex:pageBlockSectionItem>

Apex Class:
public List<SelectOption> getAvailableProductOptions(){
        availableOptions = new List<SelectOption>();
       // selectedOptions = new List<SelectOption>();
        //set<String> nameSet = new set<String>();
        for(Account qli : [Select Technology_Type__c,Name,Id
                                From Account
                                Where Technology_Type__c!=null
                                Limit 1000]){
            availableOptions.add(new selectOption(Technology_Type__c,Technology_Type__c));
        }
       
        return availableOptions;
    }
bob_buzzardbob_buzzard
There's nothing in the code that you posted to retrieve accounts based on the selected options - you've just posted the code that sets up the available selectlist options.  Can you post the code that is executed when the user clicks the button?
mchandramchandra
public PageReference updateAccountFilters() {

        resetAccountSelectList();
      
        system.Debug('selected TechnologyOptions----'+selectedOptions);
        List<String> selectedTechOptions = new List<String>();
        if( selectedOptions.size() > 0 ){
           
            system.Debug('selectedTechOptionsArr---'+selectedOptions);
        }
        System.Debug('selected Country----'+selectedCountry);
        System.Debug('selected Sub Region----'+selectedSubRegion);
        accountsList = new List<AccountRecords>();
        if (selectedRegion != NULL && selectedRegion != SELECT_ALL_VALUE) {
            List<SelectOption> tempListSelectOption =  new List<SelectOption>();
            if( selectedCountry != NULL && selectedCountry != SELECT_ALL_VALUE ){              
                if (mapCountryAccount.containskey(selectedCountry)) {
                    String name;
                    String techname;
                    for (Account objAccount : mapCountryAccount.get(selectedCountry)) {                    
                        if (objAccount!=null) {
                            if( selectedOptions.size() > 0 ){
                                for(SelectOption eachTechOption:selectedOptions){
                                    String accountBasedTechOptions = ';' + objAccount.Technology_Type__c + ';';
                                    if( accountBasedTechOptions.contains( ';'+eachTechOption.getValue()+';')){                                 
                                        AccountRecords eachRec = new AccountRecords();
                                        name = objAccount.name.length()>25 ? objAccount.name.substring(0,25)+'..' : objAccount.Name;
                                        tempListSelectOption.add(new SelectOption(objAccount.Id,name));
                                        eachRec.recName = name;
                                        eachRec.techName=objAccount.Technology_Type__c;
                                        eachRec.isSelected = false;
                                        eachRec.id = String.valueOf(objAccount.id);
                                        accountsList.add(eachRec);
                                    }//Account Technology has selected filter value
                                }//Loop Over selected Technology Values
                            }else{
                                AccountRecords eachRec = new AccountRecords();
                                name = objAccount.name.length()>25 ? objAccount.name.substring(0,25)+'..' : objAccount.Name;
                                tempListSelectOption.add(new SelectOption(objAccount.Id,name));
                                eachRec.recName = name;
                                eachRec.techName=objAccount.Technology_Type__c;
                                eachRec.isSelected = false;
                                eachRec.id = String.valueOf(objAccount.id);
                                accountsList.add(eachRec);
                            }                          
                        }//If Acc Rec is not null
                    }//Loop Over Country based accounts
                }//Region & SubRegion & Country based Results
            }
            else if( selectedSubRegion != NULL && selectedSubRegion != SELECT_ALL_VALUE ){ 
                system.debug('---mapSubRegionCountry size--'+mapSubRegionCountry);
                system.debug('----mapSubRegionCountry ---'+mapSubRegionCountry);
                if (mapSubRegionCountry.containskey(selectedSubRegion)) {
                    System.Debug('selected Sub Region----'+selectedSubRegion);
                    Set<String> countriesList = mapSubRegionCountry.get(selectedSubRegion);
                    system.debug('# of countries: '+countriesList.size());
                    for(String eachCountry: countriesList){
                        if (mapCountryAccount.containskey(eachCountry)) {
                            String name;
                            String techname;
                            for (Account objAccount : mapCountryAccount.get(eachCountry)) {
                                if (objAccount!=null) {
                                    if( selectedOptions.size() > 0 ){
                                        for(SelectOption eachTechOption:selectedOptions){
                                            String accountBasedTechOptions = ';' + objAccount.Technology_Type__c + ';';
                                            if( accountBasedTechOptions.contains( ';'+eachTechOption.getValue()+';')){                                         
                                                AccountRecords eachRec = new AccountRecords();
                                                name = objAccount.name.length()>25 ? objAccount.name.substring(0,25)+'..' : objAccount.Name;
                                                tempListSelectOption.add(new SelectOption(objAccount.Id,name));
                                                eachRec.recName = name;
                                                eachRec.techName=objAccount.Technology_Type__c;
                                                eachRec.isSelected = false;
                                                eachRec.id = String.valueOf(objAccount.id);
                                                accountsList.add(eachRec);
                                            }//If Account has selected Technology Options
                                        }//Loop Over Selected Technology Options
                                    }else{
                                        AccountRecords eachRec = new AccountRecords();
                                        name = objAccount.name.length()>25 ? objAccount.name.substring(0,25)+'..' : objAccount.Name;
                                        tempListSelectOption.add(new SelectOption(objAccount.Id,name));
                                        eachRec.recName = name;
                                        eachRec.techName=objAccount.Technology_Type__c;
                                        eachRec.isSelected = false;
                                        eachRec.id = String.valueOf(objAccount.id);
                                        accountsList.add(eachRec);
                                    }                                                                     
                                }//If Account Rec is not null
                            }//Loop Over Country based accounts
                        }//Get Accounts per Country                    
                    }//Loop over each Country of a Sub Region
                }//If SubRegion based account records Exist                                
            } // Region & Sub Region based results
            else{//SHOW ACCOUNTS BASED ON REGION
                if( mapRegionAccount.containsKey(selectedRegion) ){
                    String name;
                    String techname;
                    for (Account objAccount : mapRegionAccount.get(selectedRegion)) {                    
                        if (objAccount!=null) {
                            if( selectedOptions.size() > 0 ){
                                for(SelectOption eachTechOption:selectedOptions){
                                    String accountBasedTechOptions = ';' + objAccount.Technology_Type__c + ';';
                                    if( accountBasedTechOptions.contains( ';'+eachTechOption.getValue()+';')){                                 
                                        AccountRecords eachRec = new AccountRecords();
                                        name = objAccount.name.length()>25 ? objAccount.name.substring(0,25)+'..' : objAccount.Name;
                                        tempListSelectOption.add(new SelectOption(objAccount.Id,name));
                                        eachRec.recName = name;
                                        eachRec.techName=objAccount.Technology_Type__c;
                                        eachRec.isSelected = false;
                                        eachRec.id = String.valueOf(objAccount.id);
                                        accountsList.add(eachRec);
                                    }//Account Technology has selected filter value
                                }//Loop Over selected Technology Values
                            }else{
                                AccountRecords eachRec = new AccountRecords();
                                name = objAccount.name.length()>25 ? objAccount.name.substring(0,25)+'..' : objAccount.Name;
                                tempListSelectOption.add(new SelectOption(objAccount.Id,name));
                                eachRec.recName = name;
                                eachRec.techName=objAccount.Technology_Type__c;
                                eachRec.isSelected = false;
                                eachRec.id = String.valueOf(objAccount.id);
                                accountsList.add(eachRec);
                            }                          
                        }//If Acc Rec is not null
                    }
                }          
            }
            if( accountsList.size() > 0 ){
               
                accountsPaginationObj = new Pagination(accountsList,8);
                system.Debug('--Pagination Object Set---'+accountsPaginationObj);
            }
           
            if( tempListSelectOption.size() > 0 ){
                tempListSelectOption = SortOptionList(tempListSelectOption);
                accountSelectList.addall(tempListSelectOption);
            }
        }

        return null;