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
Steve ChadbournSteve Chadbourn 

ActionSupport and lookup field

I'm trying to get an actionSupport to work with a lookup field.

Code:
<apex:inputField id="adviser" value="{!claimNotification.Adviser__c}">
 <apex:actionSupport action="{!updateAdviserDetails}" event="onchange" immediate="false" status="stat" rerender="adviserEmail,adviserPhone,adviserFax" />
</apex:inputField>



It works if I type the name of the new adviser in the textbox and tab out of the field but does not work if I click the search button next to the lookup field and select a new adviser that way.

How do I trigger the actionSupport when the search button is clicked?


Ron HessRon Hess
That's a tough one, you may have to bind to the dom element for that button, i don't believe it's exposed directly by parameters to the input field or the action support.
Steve ChadbournSteve Chadbourn

Thanks Ron. OnBlur seems a little better but still not what I want.

I'm hoping this will be fixed at some point as I consider this to be missing functionality. Hopefully as Visualforce matures things like this will get cleaned up.

dchasmandchasman
It is a gap in functionality and we have an enhancement request/bug tracking this but it has not been fixed yet.
MohanaGopalMohanaGopal
Hi...
     Steve.
 
Can u post ur visual force code and Apex class code ( Getting Lookup field value in Apex class and set field
 values in visual force page)...
 
I am in same situation...
 
Please post ur code...
 
 
 
B2000B2000

It's been a while since the orignial post.  I've tried using action support and action function with onblur, onchange, etc.  with no luck.  What is the best way to do an action on a lookup field such as whoId on task after it returns from the lookup?

Thanks.

Rajesh ShahRajesh Shah
I too am in the same situation. Were you able to find a better way for this to work. onchange doesn't works when value is updated from lookup icon. I am thinking of using javascript and actionFunction.
B2000B2000
That is what I did.
Rajesh ShahRajesh Shah

Will it be possible for you to provide a sample code of how you did it? I have never understood action function completely; always end up facing some problem with them not working.

 

Thanks.

B2000B2000

Here is some code to get you going.  HoldAccount is an Account object to obtain the Selected Status picklist field. When the HoldAccount select option changes, the chgStatusSelected function executes.

<apex:form id="form1"> <apex:actionFunction action="{!chgStatusSelected}" name="chgStatusSelected" rerender="Account" /> <apex:pageBlock id="Account"> <apex:selectList value="{!holdAccount.status}" multiselect="false" size="1" onchange="chgStatusSelected();" > <apex:selectOptions value="{!statusList}" /> </apex:selectList> </apex:pageBlock> Account holdAccount; public List<SelectOption> getStatusList() { return statusOptions; } public String getStatusSelected() { return statusSelected; } public PageReference chgStatusSelected() { statusSelected = holdAccount.Status; statusChgFlag = true; return null; }

 

 

 

Message Edited by Brian Conlon on 07-27-2009 03:49 PM
TLFTLF

I initially implemented this by adding actionSupport to the lookup inputField with the event attribute set to "onblur". It worked... sort of. It was a bit clunky, since it seems that the blur event was firing twice. Today, I tried changing the actionSupport to use the "onchange" event. It seems like selecting a record from the search dialog is now firing the "change" event, so, perhaps Salesforce has fixed the issue originally reported here. Doug Chasman, are you able to confirm this was fixed?

Mike PardMike Pard
Hi all

Does someone has a solution ?


Thank you