function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sale IT UPSale IT UP 

Not able to display the Related Child record on Visualforce Page

APEX code:

public with sharing class InnerSOQLQuery {
    
    
    public List<Invoice__c> invList {get;set;}
    
   public List<Item_Detail__c> itemDetail {get;set;}
    
    public  void getRelatedRecords(){
   
     itemDetail = new List<Item_Detail__c>();
            
 invList = [SELECT Invoice_Number_c, Product_Detailsc, (SELECT Name, Quantityc, Ratec FROM Item_Detailsr LIMIT 7) FROM Invoice_c WHERE Id = 'a015w00001FG4gz'];
      
        for(Invoice__c Invs:invList){
            
            for( Item_Detail_c itm:Invs.Item_Details_r){
                itemDetail.add(itm);
                system.debug('Item Name-->'+ itm.Name+ '-->Rate-->'+itm.Rate_c + '-->Quantity-->'+itm.Quantity_c);
            }
        }  
        system.debug('Item Name-->'+ itemDetail);
       
    }
}

VF Code>

<apex:page controller="InnerSOQLQuery"   docType="html-5.0" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="true">

  <apex:pageBlock title="My Content">
    <apex:repeat value="{!invList}" var="acct">
        <apex:outputText value="{!acct.Product_Details__c}"/>
        
        <apex:repeat value="{!acct.Item_Details__r}" var="obj2">
            <apex:outputText value="{!obj2.Name}"/>
        </apex:repeat>
    </apex:repeat>
</apex:pageBlock>
</apex:page>

Result:

Blank Page


But my Controller shows proper Output while executing via Anonymous window:

It fetches Child records

VinayVinay (Salesforce Developers) 
Hi,

Can you check if you are missing to include standard controller?

Thanks,
Vinay Kumar