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

Need Help Storing Picklist Value in an Apex Parameter


I have a custom related list built on a Visual Force that we have embedded on the Account Layout. This related list shows a series of custom Sales Team records. Above the related list, we have a picklist that displays various regions. We want users to be able to use this picklist as a filter so that when they select a region from the dropdown and click a button, the related list filters to only display the records who region matches the value selected in the picklist.

I am having trouble getting the selected value in the picklist to be referenced in my Apex Class.

Here is a subset of my code:

This is my Region picklist. It pulls the list of values from an Apex function
<apex:selectList size="1" id="regionfilter">
        <apex:selectOptions value="{!DistinctRegionValuesFilter}"></apex:selectOptions>

This is my button on the form. The attribute I am having trouble with is the value attribute. I want to pass in the selected picklist value, but that is not happening. Instead, my debugs show that my region parameter is null:
<apex:commandButton value="Go" action="{!refreshRelatedList}" reRender="form">
    <apex:param name="region" value="regionfilter"/>

However, if I hardcode the value attribute to one of my regions, such as USA, whenever I click the button, it successfully filters my related list to only show Sales Teams with USA as the region.
<apex:commandButton value="Go" action="{!refreshRelatedList}" reRender="form">
    <apex:param name="region" value="USA"/>

I feel like I'm close, so does anyone know of a simple way I can have the selected picklist value be stored as my apex parameter?

Ankit AroraAnkit Arora
Why you want that to be sent via apex:param? You can use value in select list to directly bind the value from your apex class variable like this :

<apex:selectList value="{!YourApexVariable}" size="1" id="regionfilter">

Let me know if that helps.