2

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>
3

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:

public class Advanced_Approval {
public Apttus_Approval__Approval_Request__c reassignee {get;set;}
User reassignedToUser = new User();

public Advanced_Approval() {
    reassignee = new Apttus_Approval__Approval_Request__c();
}

public void userPopulated()  {
    system.debug('Reassignee ID: ' + reassignee.Apttus_Approval__Assigned_To__c);
    reassignedToUser = [select id, Name From User Where id=:reassignee.Apttus_Approval__Assigned_To__c];
    }
}
  • A concise example would probably make this a stronger answer. – Adrian Larson Jan 26 '16 at 16:38
  • At your service. :) – Sebastian Kessel Jan 26 '16 at 16:38
  • 1
    Haha I would write it but you were so close to having the right answer already. +1 now that it's there. – Adrian Larson Jan 26 '16 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.