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
GazzaGazza 

Visualforce Dependent Picklist actionSupport Problem

Hi,

 

The Problem I’m having is that the actionSupport function SearchTemplates from my dependent picklist is only running once when I set the value. When I change the values again it does not run my SearchTemplates method. What is happening is that Salesforce is removing the onchange event from my select list after running the action once. I think this maybe a Salesforce bug. Is there a workaround with out changing my data model?

 

Below is a simple code example of what I am trying to do:

 

Visualforce Page

 

<apex:page controller="TemplateCont" >
<apex:form >
<apex:actionRegion >
<apex:inputField value="{!aTemplate.Category__c}"/>
<apex:inputField value="{!aTemplate.Subcategory__c}">
<apex:actionSupport action="{!SearchTemplates}" event="onchange" rerender="matchingTemplates" status="status"/>
</apex:inputField>
<apex:actionStatus startText=" Please wait..." id="status"/>
</apex:actionRegion>

<apex:pageBlock title="Matching Templates" id="matchingTemplates" >

{!MatchingTemplates.size}

</apex:pageBlock>

</apex:form>
</apex:page>

Controller

 

 

public with sharing class TemplateCont {
public Template__c aTemplate{get; set;}
public List<Template__c> matchingTemplates{get; private set;}
public TemplateCont(){ aTemplate = new Template__c(); matchingTemplates = new List<Template__c>(); } public void SearchTemplates(){ matchingTemplates = [SELECT name, category__c, subcategory__c FROM Template__c where category__c=:aTemplate.Category__c and subCategory__c=:aTemplate.Subcategory__c]; } }

 

 

Would be greatfull for any help.

 

Thanks

 

Peter

bob_buzzardbob_buzzard

Have you tried re-rendering the section contained by your actionregion as well as the results list? 

GazzaGazza

I tryed re-rendering the section contained by the actionregion and it does not work. I found out that if I changed the apiVersion down to 18.0 from 19.0 it would work but you do not get the dependent picklist functionality which is needed. Is this a Salesforce bug?

AYNAYN

I too am facing this problem. Onchange event works fine sometimes but doesnt other times.

 

 

<apex:inputFiled value="{!opportuniyt.ControllingField__c}" onchange="alert('hi');"/>

 

 

 

But it works fine one time when I use onblur event instead of onchange and after that one time nothing happens.

 

 

<script>
function dummyFunctionJS() {
    alert('before ');
    dummyFuncJSFunc();
    alert('after');
    }
</script>
<apex:actionFunction name="dummyFuncJSFunc" action="{!dummyFunc}" reRender="parentPanelId" immediate="true" onbeforedomupdate="alert('dom update alert');"/>
<apex:inputFiled value="{!opportuniyt.ControllingField__c}" onblur="actionFunctionMethod();"/>

 

 

boratborat

I filed a bug with salesforce where actionSupport doesn't work on the "child" of a dependent picklist.  They've agreed it's indeed a bug and I got the feeling the timeframe was 6+ months out.  They suggested that I use the onchange event instead, which works great, but if you integrate it with an actionFunction, it only does the desired behavior once.  

 

I also bumped down the api version to 18 from 19 and the actionFunction fires on more than the one time.  So I believe these two issues are related.

hokusaihokusai

any update on this? 

cpoiteviencpoitevien

No updates with this bug. I have ran into the same problem.

jordanmjordanm

So years after initial reporting of this and its still broken????

 

BosDogBosDog

i am faced with this problem as well. what is the bug tracking # we should get on top of SFDC to fix this. 2 years of a reported bug that they admitted is a bug is not acceptable.

Vijay s 16Vijay s 16
Any updates on this. I am struck with this. Any workaround or solution will be helpful
Antonio Luzio 5Antonio Luzio 5
Same problem is happening with me. :-(