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
GhanashyamGhanashyam 

Picklist returns blank value during AJAX call

Hi,
I have a picklist field with some values in a visualforce page. I want to make an AJAX request to the detail section(below) as and when a picklist value is selected.
<apex:outputpanel>
<apex:actionsupport event="onclick" rerender="resultPanel">
                   <apex:param name="enqtype" value="{!case.Enquiry_Type__c}"></apex:param>
</apex:actionsupport>
</apex:outputpanel>
 
In the same visualforce page, when I tried to use the selected picklist value( as shown in the following code), it returns blank value.
 
<apex:column headerValue="Email">{!$CurrentPage.parameters.enqtype} &nbsp; </apex:column>
In the following code in Custom Controller class the expression ":ApexPages.CurrentPage().getParameters().get('enqtype')" doesn't resolve to the selected picklist value and returns blank value as well.
 
cases = [select id, CreatedDate,SuppliedEmail,Suppliedname,description,enquiry_type__c from Case
                     where enquiry_type__c = :ApexPages.CurrentPage().getParameters().get('enqtype')];
 
Can someone enlighten me on why I get blank values. Thank you
 
 
Ghanashyam
 
Ron HessRon Hess
That is not how you access the selected picklist value

if Enquiry_Type__c  is your custom picklist field

then you must have an inputField somewhere, i did not see that in your code sample, but if you do then the user selection would be stored in case.Enquiry_Type__c

not
{!$CurrentPage.parameters.enqtype}

or
ApexPages.CurrentPage().getParameters().get('enqtype')


really need more code to understand why you are getting blanks
GhanashyamGhanashyam

Hi Ron,

Thanks for the reply. Please see below the complete code.

This is what I am trying to achieve: Whenever a new queue is chosen in 'Selected queue' picklist, the data table alone should get refreshed and only those records that match the selected queue should be displayed.

The current behaviour is that the records get refreshed as and when a new queue is selected but they are not getting filtered based on the selected queue. I am not sure if I am missing anything obvious here.

+++++++++++++++ Visual Page code: Begin ++++++++++++++++++++++++++


<apex:page standardcontroller="case" extensions="dataTableCon" id="thePage">
    <apex:Form >
        <apex:pageBlock title="Enquiry Management">
          
            <apex:outputpanel >
              <h1>Selected queue:</h1>   
              <apex:inputField id="enqtypeid" value="{!case.Enquiry_Type__c}"></apex:inputField>
              <apex:actionsupport event="onclick" rerender="resultPanel">
                  <apex:param name="enqtype" value="{!case.Enquiry_Type__c}"></apex:param>
              </apex:actionsupport>
            </apex:outputpanel>

                <br>
         </apex:pageBlock>

        <apex:pageBlock title="Enquiry Queue">
            <apex:outputPanel id="resultPanel" layout="block">
                <apex:pageBlockTable value="{!cases}" var="cas" columnswidth="10%,10%,20%,20%,40%">
                    <apex:column headerValue="Due date">{!Now()} &nbsp; </apex:column>
                    <apex:column headerValue="Type">{!case.Enquiry_Type__c} &nbsp; </apex:column>
                    <apex:column headerValue="Company">{!cas.SuppliedName} &nbsp; </apex:column>
                    <apex:column headerValue="Enquiry">
                        <apex:outputLink value="https://na1.salesforce.com/{!cas.id}">{!cas.description} &nbsp;</apex:outputLink>    
                    </apex:column>
                </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:Form>
</apex:page>

+++++++++++++++ Visual Page code: End ++++++++++++++++++++++++++

 

The following is the code of class dataTableCon

public class dataTableCon {
    public dataTableCon(ApexPages.StandardController controller) {

    }


    List<Case> cases;

    public List<Case> getCases(){
        if(cases== null)
        {
         cases = [select id, CreatedDate,SuppliedEmail,Suppliedname,description,enquiry_type__c from Case where enquiry_type__c=:ApexPages.currentPage().getParameters().get('enqtypeid')];
        }
        return cases;
    }
   
}

 

 

Thanks

Ghanashyam

 

 
Ron HessRon Hess
cases is not going to change each time since you first check for null

cases is set once, after that it is never null since it is part of the viewstate of the controller.

remove the statement
if(cases== null)

and it should change when you change the inquiry type
GhanashyamGhanashyam

Thanks Ron. I did remove the null check for cases but for some reason the records do not get filtered as I change the 'enquiry type'. The records get filtered when I hard code the condition in the apex class. Something like the following...

Code:
cases = [select id, CreatedDate,SuppliedEmail,Suppliedname,description,enquiry_type__c from Case where enquiry_type__c= 'Delete requests'];

 
But if I use a generic statement like the following in the controller class, the expression :ApexPages.currentPage().getParameters().get('enqtype') doesn't get resolved properly and the system considers the value of this expression as 'null' and returns all records where the value of the 'enquiry type' field is null.
 
Code:
         cases = [select id, CreatedDate,SuppliedEmail,Suppliedname,description,enquiry_type__c from Case where enquiry_type__c= :ApexPages.currentPage().getParameters().get('enqtype')];
 
Can you tell me what could be wrong here or is there any better way to pass the values to the controller class.
 
 
Many thanks
Ghanashyam