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
Charles McDowellCharles McDowell 

Controller Extension Query child and a child of the child

I have have four objects 1:Project__c   2:Child - Quote__c   3: Child: QuoteDetail__c  4:Child: QuotePrice__c
here is my code. I get an error the q.ID is not recognized.  Can someone tell what I am doing wrong? Thanks
here is my code

public class ProjectRptExtension {
    Public List<Quote__c> q {get;set;}
    Public List<QuoteDetail__c> qd {get;set;}
    Public List<QuotePrice__c> qp {get;set;}
    
    Public ProjectRptExtension(apexPages.StandardController controller){
        Set<ID> setQDid = new Set<ID>();
       
        ID MyId = apexpages.currentPage().getParameters().get('id');
      // Project__c  = (Project__c)controller.getRecord();

        
        q   = [Select ID, Name, System__c, Coverage_Area__c, System_Price__c, Project__c From 
            Quote__c Where  Project__c = : MyID limit 1];     
        
        
        qd = [Select  Name, Product__c, Product_Category__c, Order_In_System__c, Product_Total__c,
                 Coverage_Density__c, Quantity__c From QuoteDetail__c  
              Where Quote__c = : q.Id];
        
        For (QuoteDetail__c qdt: qd){
            setQDid.add(qdt.id);
        }
            
        
        qp = [Select ProductSizePrice__c, Quantity__c, List_Price__c, Ext__c 
              From QuotePrice__c Where QuoteDetail__c in : setQDid];
    }
}







 
Rahul.MishraRahul.Mishra
Hi Charles, problem is with QuoteDetails query where you are storing the result in qd, you are filtering the QuoteDetails based on parent Quote, since you stored parent quote in list, you have to update the where conditon slightly:
Where Quote__c = : q[0].Id]

 
Rahul.MishraRahul.Mishra
Please do not forget to mark it as a best answer if it helps you.
Charles McDowellCharles McDowell
Thanks Rahul that solved that problem.  I have another issue I get the data from the controller extension, but I want nest three levels
Quote
     QuoteDetail
          QuotePricing
But I get QuoteDetail nested but the Quote Pricing is not nested.  Here is my markup and thanks for your help

<apex:page standardController="Project__c" extensions="ProjectRptExtension" >
    <apex:form >
        <b>{!Project__c.Name}
              <apex:pageBlock >
                  <apex:pageBlockTable value="{!q}" var="g">
                    <apex:column value="{!g.name}" />
                    
                    <apex:column breakBefore="true" colspan="2" >
                            <apex:pageBlockSection Title = "Products" columns="1">
                            <apex:pageBlockTable value="{!qd}" var = "d">
                                <apex:column value="{!d.name}" />
                              </apex:pageBlockTable>     
                           </apex:pageBlockSection>
                        </apex:column >
                            
                    <apex:column breakBefore="True" colspan="2" >
                                <apex:pageBlockSection title="Pricing" columns="1">
                                    <apex:pageBlockTable value="{!qp}" var = "p">
                                        <apex:column value="{!p.ProductSizePrice__c}" />
                                     </apex:pageBlockTable>
                            </apex:pageBlockSection>    
                    </apex:column > 
                
                </apex:pageBlockTable>            
                
                    
                
           </apex:pageBlock>

        
        
        </b>
    
    </apex:form>
    
</apex:page>