You need to sign in to do that
Don't have an account?
How can I reference the value in an apex:inputField component on an unsaved record?
Here is my goal: I have a custom page for new cases. I have a custom object that contains "heads up" information on accounts called a flash. As soon as a user selects an account via the lookup icon I need to throw a modal popup that lists the messages for the selected account. I am really close to getting this to work but I need to pass the selected account name to my controller. How can I get this value? I'm thinking by id name on the apex:inputField component but I don't know how.
Here's the section of code:
<apex:pageBlockSectionItem > <apex:outputLabel value="* Account Name" styleClass="RequiredLabelColor"/> <apex:inputField id="txtAccountName" value="{!Case.AccountId}"> <apex:actionSupport event="onchange" action="{!showFlash}" rerender="FlashMessage"> <apex:param name="AcctNameParam" value="{!txtAccountName.value}" assignTo="{!strAccountName}"/> </apex:actionSupport> </apex:inputField> </apex:pageBlockSectionItem>
The value="{!txtAccountName.value}" part is a syntax error but it's how I thought it might have worked. The case record is unsaved at this moment so I cannot use {!Case.AccountId}.
Thank you!
The way that you are passing Case.AccountId will use the value that was present when the page was originally rendered.
Presumably you are using an extension controller to a Case record? If so, you don't need to pass any parameters back to the controller, the record that the standard controller is managing will be updated with the selected account id as part of the postback for the actionsupport.
All Answers
As you are using an actionSupport, you should be able to use the Case.AccountId. By the time your action method "showFlash" is executed, the Case record will be updated with the latest values from the viewstate.
Thanks for the reply!
I tried adding the Case.AccountId like you recommended.
Here's my page code snippet:
I get the following Visualforce Error:
System.QueryException: List has no rows for assignment to SObject
Here is my showFlash code snippet:
and here is my debug log:
It appears that the Case.AccountId is null when it reaches the showFlash function. Can you tell me what else I can try? Thank you very much!!!!
The way that you are passing Case.AccountId will use the value that was present when the page was originally rendered.
Presumably you are using an extension controller to a Case record? If so, you don't need to pass any parameters back to the controller, the record that the standard controller is managing will be updated with the selected account id as part of the postback for the actionsupport.
Thanks for the tip! I got it to work!