You need to sign in to do that
Don't have an account?
Christopher Pezza
What My code looks like with multiple select list:
Controller:
Visual Force Page:
Using Multiple <SelectOption> in Apex and SelectList SelectOptions
public with sharing class CustomerHealth { Public String CSMFilter {get ; set;} public Set<String> cmSet {get; set;} public CustomerHealth() { cmSet = new Set<String>(); for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(ch.Customer_Success_Manager__c); }//END for }//END public public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions= new List<SelectOption>(); for (String s : cmSet) { csmoptions.add(new SelectOption(s, s)); } return csmoptions; } }I created this an now want to create two more selct list the same as this but i get an error "Argument 1 cannot be null"
What My code looks like with multiple select list:
Controller:
public with sharing class CustomerHealth { public Set<String> cmSet {get; set;} public Set<String> amset {get; set;} public Set<String> seset {get; set;} public CustomerHealth() { cmSet = new Set<String>(); for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(ch.Customer_Success_Manager__c); }//END for amset = new Set<String>(); for(Customer_Health__c cha : [SELECT Account_Manager__c FROM Customer_Health__c]){ amset.add(cha.Account_Manager__c); } seset = new Set<String>(); for(Customer_Health__c chs : [SELECT Support_Engineer__c FROM Customer_Health__c]){ seset.add(chs.Support_Engineer__c); } }//END public public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions= new List<SelectOption>(); for (String s : cmSet) { csmoptions.add(new SelectOption(s, s)); } return csmoptions; } public List<SelectOption> getSEItems() { List<SelectOption> seoptions = new List<SelectOption>(); seoptions.add(new SelectOption('No Filter', 'Support Engineer')); seoptions.add(new SelectOption(' ', 'No SE')); for (String a : seset) { seoptions.add(new SelectOption(a, a)); } system.debug('***' + seoptions); return seoptions; } public List<SelectOption> getAMItems() { List<SelectOption> amoptions = new List<SelectOption>(); amoptions.add(new SelectOption('No Filter', 'Account Manager')); for (String d : amset) { amoptions.add(new SelectOption(d, d)); } system.debug('***' + amoptions); return amoptions; } }
Visual Force Page:
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!CSMFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!CSMItems}"></apex:selectOptions> </apex:selectList> <span class="divider"></span> <apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!SEFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!SEItems}"></apex:selectOptions> </apex:selectList> <span class="divider"></span> <apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!AMFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!AMItems}"></apex:selectOptions> </apex:selectList>
All Answers
This Error "Argument 1 cannot be null" is Founded Due To You Have No Records In List. Check One Of The Field Did You Used Is Empty ? If Empty Create Record And Try Again.
And Add This Strings In Your Code Regards
Gopal Rathore
This Code Is Working On My Side
If There Is Records In Fields.
And If Fields Are Empty It Will Give Error...
Regards
Gopal Rathore
You Have To Add WHERE Clause To Eliminate The Blanks In The Query.
Because If Empty Records Is Added To The Set It Will Show Error System.NullPointerException: Argument 1 cannot be null..
And If You Use WHERE Clause It Will Eliminate The Blanks From The Query.
After That Your Error Will Solved.
Regards
Gopal Rathore