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
Pritam Patil 19Pritam Patil 19 

Picklist Value returned in Apex Class is "null"

Hello,

I am trying to pass selected picklist value to apex class dynamically using actionsupport, but when I check using debug logs I am getting the value as null. I need this value as I have to get data from query to populate another custom picklist.

Below is my code:
VISUALFORCE PAGE:
//FIRST PICKLIST
<apex:selectList size="1" id="ApplicationDrop" value="{!ApplicationVar}"  >
            <apex:actionSupport event="onchange" reRender="FBiasR" status="rend"/>
            <apex:selectOptions value="{!ApplicationOptions}"></apex:selectOptions>
  </apex:selectList>

//SECOND PICKLIST
<apex:selectList size="1" id="FBiasR" value="{!FBiasRVar}">
             <apex:selectOptions value="{!FBRItems}"></apex:selectOptions>
</apex:selectList>

APEX CLASS:
 public  List<SelectOption> getFBRItems() {
         system.debug('APPLICATION ------------->'+ApplicationVar);
         List<SelectOption> options = new List<SelectOption>();
         options.add(new SelectOption('None','None'));
         
         for(AggregateResult ar : [Select Recommendation__c from Fleet_Recommendation__c where Axle__c = 'Front' AND Tyre_Class__c = 'Bias' AND Application__c =:ApplicationVar GROUP BY Recommendation__c])
         {
         options.add(new SelectOption(String.valueOf(ar.get('Recommendation__c')),String.valueOf(ar.get('Recommendation__c'))));
         }
          return options;
   }


I have done this same functionality on another VF page there it is working correctly with the same code. Need Help!
Best Answer chosen by Pritam Patil 19
Pritam Patil 19Pritam Patil 19
Hello,

I got the issue. Actually there were some required fields and their required validation was interfering with the reRendering of the picklists.

Tip for all who are doing this : Add <apex:pagemessages id='msgs'/> to your visualforce page and reRender 'msg' in actionSupport. So that you are notified about the errors occuring and take actions required.

All Answers

Waqar Hussain SFWaqar Hussain SF
Please see the field level security for the field Recommendation__c​,
Pritam Patil 19Pritam Patil 19
Hi Waqar,

field level security is 'Visible', the problem is i am not getting ApplicationVar in apex class hence the query is not working.
Waqar Hussain SFWaqar Hussain SF
Have you used get, set property for ApplicationVar, like 
 
public string ApplicationVar {get; set;}

 
Pritam Patil 19Pritam Patil 19
Yes I have
Pritam Patil 19Pritam Patil 19
Hello,

I got the issue. Actually there were some required fields and their required validation was interfering with the reRendering of the picklists.

Tip for all who are doing this : Add <apex:pagemessages id='msgs'/> to your visualforce page and reRender 'msg' in actionSupport. So that you are notified about the errors occuring and take actions required.
This was selected as the best answer