0

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) {
        objRequest=(PTO_Request__c)controller.getRecord();        
        System.debug('---------- objRequestConstructor -------------'+ objRequest);
    }
4
  • what is the error you are getting? Jun 11, 2014 at 11:29
  • No Error ! But there is no record in objRequest Jun 11, 2014 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.
    – S..
    Feb 3, 2017 at 6:44
  • Do not remember exactly but ...try ApexPages.StandardSetController instead of ApexPages.StandardController in function parameter Feb 8, 2017 at 15:02

3 Answers 3

1

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"/>

or

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

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.

0

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

0

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.

1
  • 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. Jun 11, 2014 at 11:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .