Having a simple apex:selectList and using apex:actionSupport to handle user selections which is working fine. Surprised that the event is not firing only for some values.


<apex:actionRegion id="salesItemActionRegion">
       <apex:outputLabel value="Sales Item : "></apex:outputLabel>
       <apex:selectList id="drpSalesItem" value="{!selectedProduct}" size="1">
           <apex:selectOptions id="optnSalesItem" value="{!ProductList}"></apex:selectOptions>
           <apex:actionSupport rerender="pnlProductInfo" action="{!LoadProductDetails}" event="onchange" />


//action fires from prduct drop down on change
    public void LoadProductDetails(){
        SalesItemWrapper wrapper = new SalesItemWrapper();  //reset wrapper
        selectedProductWrapper = new List<SalesItemWrapper>();
        System.debug('choices:' + productList);
        if(!productList.isEmpty() && productList.size() >1){
            if(selectedProduct != null && !selectedProduct.equalsIgnoreCase(MENU_SELECT_ID)){
                String[] keyArr = selectedProduct.split('-');
                wrapper.salesItemId = (keyArr != null)?keyArr[0] : '';  //tracking related sales_item__c(product) id for future reference
                wrapper.salesItemName = (keyArr != null)?keyArr[1] : ' ';
                wrapper.salesItemCode = (keyArr != null)?keyArr[2] : ' ';

I'll add the here a selectOption that's not firing the onchange event.

System.SelectOption[value="a0h90000002KMnDAAW-103 PW-Legionella spp  Plate Count (YEA) - Potable Water", label="103 PW - Legionella spp  Plate Count (YEA) - Potable Water", disabled="false"]

Tried to use apex:outputLabel with selectedProduct to check what it shows. Still no value or having previous value if any;not changing the value.

1 Answer 1


Issue is with the value of selectOption. In between the value, there are double sapces which caused to fail some salesforce validations.

In the value Legionella spp Plate Count (YEA) replaced the double space between spp and Plate with a single space and it's working fine.

As per my understanding this happens due to the way that salesforce perform server side validation for selectOption. When we select a value they forcefully replace multiple spaces with a single space and at the validation it's not get match;onchange will not fire. Any explanation about this is highly appreciated and I'll keep this answer until then so that someone get a help.

Thing to learn : Even you 110% confident with your code, have some <apex:pageMessages />inside a rerendering component. Because you can't guess when a server side validation will fail and break your code blindly, if you are not an expert :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .