0

We have two objects SieBid_Opportunity__c which is child object and SieBid_Account__c which is parent. I have created a vf page with standard controller of SieBid_Opportunity__c which shows the lookup field to SieBid_Account__c along with other fields on page. I want to fetch the field value of IFA_Number__c of whichever SieBid_Account__c record is selected by user on page through lookup. Currently it's returning null value. I have even added outputText so as to query the field but still it's returning null value in extension.

<apex:outputText value="{!opp.Account__r.IFA_Number__c}" rendered="false"/>
2
  • As far as I know, the object that the standard controller passes to the extension will be null unless you specify an Id. See this post for reference developer.salesforce.com/forums/?id=906F000000095bgIAA Commented Aug 18, 2020 at 18:17
  • @AnudeepGopagoni I have done exactly what was suggested in the answer of the link that ypu provided. I am able to get the values of all the fields that are there on VF page in extension after user input but it's not happening in case of LookUp field. I can access the Id of selected parent record selected in lookup field like opp.Account__c but when I try to access particular field like opp.Account__r.IFA_Number__c, it always returns null.
    – Rahul
    Commented Aug 18, 2020 at 20:31

2 Answers 2

0

Related record fields aren't automatically queried by the StandardController.getRecord() method

The related record Id is returned in the Standard Controller query at least, so you will be able to run a separate query to retrieve the related record fields for use in a separate variable

0

Fields visible in Visualforce are retrieved by default. However because I see that you have set the rendered=false it means is invisible on your case.

If you still want to retrieve that field, you will have to use addFields(fieldNames) on the extension constructor, see the docs: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_ApexPages_StandardController_addFields.htm

You must log in to answer this question.

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