I am trying to pass the value of an inputfield for a lookup field from my Visualforce page to my controller. I can't seem to figure out why, but it continues to return a null value. See below for some snippets of the code. If the below isn't enough and you need more of the code, let me know and I'll post more. The debug returns "Reassignee ID: null"
Controller:
public class Advanced_Approval {
public Apttus_Approval__Approval_Request__c reassignee {get;set;}
User reassignedToUser = new User();
public void userPopulated()
{
reassignee = new Apttus_Approval__Approval_Request__c();
system.debug('Reassignee ID: ' + reassignee.Apttus_Approval__Assigned_To__c);
reassignedToUser = [select id, Name From User Where id=:reassignee.Apttus_Approval__Assigned_To__c];
}
}
Visualforce Page:
<apex:outputLabel value="Reassign To " for="assigned" style="font-weight:bold; margin-left 15%" ></apex:outputLabel>
<apex:actionRegion >
<apex:inputField id="assigned" value="{!reassignee.Apttus_Approval__Assigned_To__c}">
<apex:actionSupport event="onchange" action="{!userPopulated}" rerender="FinancialAidPanel shopDetailSection" />
</apex:inputField>
</apex:actionRegion>
Best Answer
You are reinitializing the object on the line
reassignee = new Apttus_Approval__Approval_Request__c();
, you'll never see the value coming from the controller that way.Ensure that the object is initialized in a constructor, and don't "reset it" in the method. :)
For example, your class would look like this: