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
Gaurav Jain 103Gaurav Jain 103 

SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object.

While saving the below code:

 <apex:pageBlockTable value="{!Quote__c.quote_items__r}" var="line" border="1" headerClass="headerStyle" >
            <apex:column headerValue="Product #" value="{!line.product__r.Name}" width="150px;" />
                  <apex:column breakBefore="true" colspan="8">                <apex:pageBlockTable value="{!line.Product_Items__r}" var="c" border="1" headerClass="headerStyle" >
                    <apex:column value="{!c.Id}"/>
                    <apex:column value="{!c.Name}"/>               
                </apex:pageBlockTable>
                 </apex:column>
                </apex:pageBlockTable>

I got the error:
Error: Object type not accessible. Please check permissions and make sure the object is not in development mode: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object
Arun KumarArun Kumar
Hi Gaurav,

This is the limitation of Salesforce:
  • In each specified relationship, no more than five levels can be specified in a child-to-parent relationship. For example,Contact.Account.Owner.FirstName (three levels).
  • In each specified relationship, only one level of parent-to-child relationship can be specified in a query. For example, if the FROM clause specifies Account, the SELECT clause can only specify the Contact or other objects at that level. It could not specify a child object of Contact.