Here is snippet of constructor : I have VF page where there is lookup field, onchange of that lookup field I have to render some other fields from another Object using SOQL ---- I have called the method for that and Plz NOTICE I am not getting the StandardController record fields values in that method also

 public PTORequestController(ApexPages.StandardController controller) {
        System.debug('---------- objRequestConstructor -------------'+ objRequest);
  • what is the error you are getting? – AtulRajguru9 Jun 11 '14 at 11:29
  • No Error ! But there is no record in objRequest – Salesforce Steps Jun 11 '14 at 11:31
  • Any update? How did you get it to work? I'm facing the same issue in Force.com, no lookup field though. getRecord not working. My question here. – N.. Feb 3 '17 at 6:44
  • Do not remember exactly but ...try ApexPages.StandardSetController instead of ApexPages.StandardController in function parameter – Salesforce Steps Feb 8 '17 at 15:02

For your problem I am assuming that PTO_Request__c has xyz field as lookup field. Then in your VF page you will be writing code as :

<apex:inputField value="{!objRequest.xyz__c}"/>

The above code will make it as lookup field on page. And now you have to add onchange event, so for this either you have to use javascript function or you can use as:

<apex:inputField value="{!objRequest.xyz__c}" onchange="change();"/>
<apex:actionFunction name="change" action="{!methodName}" rerender="none"/>


<apex:inputField value="{!objRequest.xyz__c}">
   <apex:actionSupport event="onchange" action="{!methodName}" rerender="none"/>

And in controller you can write the method as :

public PageReference methodName(){
    // Here you will get "objRequest.xyz__c" and perform the logic here

Hope this will help you.


I think your code is fine. Make sure you are passing ID of valid PTO_Request__c object


have you added the id in the URL of the VF Page like "?id=Id of the PTO_Request__c record" ?

Eg. na1.salesforce.com/apex/yourvfpage?id=00XXXXX

where 00XXXXX is the Id of PTO_Request__c record.

  • No, I think that isn't necessory, See, I have to fetch value of one Inputfield on its onChange event, which is i am not able to take out. – Salesforce Steps Jun 11 '14 at 11:45

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.