I'm trying to render an item from one related list on PDF. the structure is following:
I have Sales Order, where is lookup field to Company, on Company is related list of Bank Accounts which I need to render. The Bank Accounts are related to Company through lookup, not master-detail. Here is code which I'm using:

<apex:repeat value="{!salesInvoice.c2g__OwnerCompany__r.c2g__BankAccounts__r}" var="account">  
<apex:outputText value="{!account.c2g__AccountName__c}" rendered="true" escape="false"/>

But get an error:

Error: Aggregate Relationship is used in an unsupported complex expression containing 'c2g__OwnerCompany__r.c2g__bankaccounts__r'

Any ideas?

1 Answer 1


You cannot bind two levels down child relationships.

Your apex:repeat binding looks like this:


The problem is that c2g__OwnerCompany__r is a list. But you're trying to tell the interator to bind to a list within a list: c2g__OwnerCompany__r.c2g__BankAccounts__r.

This is not allowed.

In theory you could do something like:

<apex:repeat value="{!salesInvoice.c2g__OwnerCompany__r}" var="ownerCompany">  
  <apex:repeat value="{!ownerCompany.c2G__BankAccounts__r}" var="account">
    <apex:outputText value="{!account.c2g__AccountName__c}" rendered="true" escape="false"/>

This would give you the ability to list all children of children.

  • 1
    Thanks for answer. Tried it and the error is still the same. In the second line the c2g__BankAccounts__r should be name of the lookup relationship on a Bank Account, right?
    – mascot
    Commented May 12, 2015 at 8:57
  • Didn't work for me
    – zaitsman
    Commented Oct 31, 2019 at 6:10

You must log in to answer this question.

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