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
jordanmjordanm 

Controller Extension that moves down through 2 children

Hello,

I am getting this error:

Save 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

 

I basically have a family object, which can have multiple participant objects in it, and each of those participants have a specific relationship within the family. I have a junction object called Family Relationship that is a child to both Family and Participant objects

 

Here is my page/code: 

<apex:page standardController="Family__c" showHeader="false" renderAs="pdf">
    <body>
        <apex:stylesheet value="{!URLFOR($Resource.pdfresource, 'styles.css')}"/>
        <apex:image value="{!URLFOR($Resource.pdfresource, 'logo.gif')}"/>
        <apex:panelGrid columns="1" styleClass="companyTable" width="100%">
            <apex:outputText value="{!$Organization.Name}" styleClass="companyName"/>
            <apex:outputText value="{!$Organization.Street}"/>
            <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}"/>
            <apex:outputText value="{!$Organization.Phone}"/>
        </apex:panelGrid>
        <apex:outputPanel layout="block" styleClass="line"/>
        <apex:panelGrid columns="1" styleClass="centered" width="100%">
            <apex:panelGrid columns="2" width="100%" cellpadding="0" cellspacing="0" columnClasses="left,right">
                <apex:outputText value="Family# {!Family__c.name}"  styleClass="customerName"/>
                <apex:outputField value="{!Family__c.lastmodifieddate}" style="text-align:right"/>
	            <apex:outputText value="Total Family Income: "/>
	            <apex:outputField value="{!Family__c.Family_Income__c}"/>
	            <apex:outputText value="Family Size: "/>
	            <apex:outputField value="{!Family__c.Family_Size__c}"/>
	            <apex:outputText value="Family Type: "/>
	            <apex:outputField value="{!Family__c.Family_Type__c}"/>
            </apex:panelGrid>
        </apex:panelGrid>
        <apex:repeat value="{!Family__c.Family_Households__r}" var="fhh">
        <apex:outputPanel layout="block" styleClass="lineSmall"/>
        <apex:outputText value="Address Type: {!fhh.Address__r.Address_Type__c}"/>
        <apex:panelGrid columns="1" styleClass="centered" width="100%">
            <apex:outputText value="{!fhh.Address__r.Address_1__c} {!fhh.Address__r.Address_2__c}"/>
            <apex:outputText value="{!fhh.Address__r.City__c}, {!fhh.Address__r.State__c} {!fhh.Address__r.Zip__c}"/>
        </apex:panelGrid>
        </apex:repeat>
        <apex:outputPanel layout="block" styleClass="lineSmall"/>
        <apex:repeat value="{!Family__c.Family_Members__r}" var="mem">
            <apex:panelGrid columns="2" columnClasses="left,right" width="100%">
                <apex:panelGroup >
                    <apex:outputText value="{!mem.First_Name__c} {!mem.Middle_Name__c} {!mem.Last_Name__c}" styleClass="productName"/>
                    <apex:outputPanel layout="block" styleClass="productDetail">
                        <apex:panelGrid columns="2" columnClasses="left,none">
                            <apex:repeat value="{!mem.FamilyRel__r}" var="rel">
                            	<apex:outputText value="Relationship: " style="font-weight:bold"/>
                            	<apex:outputField value="{!rel.Relationship__c}"/>
                            </apex:repeat>
                            <apex:outputText value="Social Security Number:" style="font-weight:bold"/>
                            <apex:outputField value="{!mem.Social_Security_Number__c}"/>
                            <apex:outputText value="Gender:" style="font-weight:bold"/>
                            <apex:outputField value="{!mem.Gender__c}"/>
                        </apex:panelGrid>
                    </apex:outputPanel>
                </apex:panelGroup>
                <apex:outputField value="{!mem.Total_Income__c}" styleClass="productName"/>
            </apex:panelGrid>
        </apex:repeat>
        <apex:outputPanel layout="block" styleClass="line"/>
    </body>
</apex:page>

 this code block, specifically, creates the error, because I'm trying to move from family to participant (1 level) and then an additional level to the relationship junction object.

<apex:repeat value="{!mem.FamilyRel__r}" var="rel">
                            	<apex:outputText value="Relationship: " style="font-weight:bold"/>
                            	<apex:outputField value="{!rel.Relationship__c}"/>
                            </apex:repeat>

 

I know this is illegal. The question is how do I go about writing an extension to accomodate this case?

 

Any guidance would be appreciated, thank you!

Best Answer chosen by Admin (Salesforce Developers) 
jordanmjordanm

 found this older thread on this topic, but not sure how to go about implementing the controller talked about...

 

http://forums.sforce.com/t5/forums/forumtopicprintpage/board-id/general_development/message-id/55159/print-single-message/false/page/1