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
goabhigogoabhigo 

Aggregate Relationship is used in an unsupported complex expression

 

This is my VF code:

 

<apex:dataTable value="{!Order__c.Opportunity__r.OpportunityLineItems}" var="d">
	<apex:column headerValue="Desc" value="{!d.Description}"/>
</apex:dataTable>

 

I am receiving an error: Error: Aggregate Relationship is used in an unsupported complex expression containing 'opportunity__r.opportunitylineitems'

 

 

Order__c is a custom object which has master-detail relationship with opportunity. I am trying to display the OpportunityLineItem details in a VF page on click of a button(Generate Order, present in Order detail page).

 

Can anybody explain whats wrong?

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

It looks like this message is coming from whatever code is used to generate the SOQL query from the page.  I've tried various ways to split the reference (using apex:variable or a custom component) but no dice.

 

The only way I could get this to fly was using two separate pages and an apex:iframe.

 

Page 1:

 

 

<apex:page standardController="Opportunity">
   <apex:outputText value="{!Opportunity.Account}" rendered="false" />
   <apex:iframe src="/apex/AggTestPage2?id={!Opportunity.AccountId}" />
</apex:page>

 

Page 2 (named AggTestPage2):

 

 

<apex:page standardController="Account" showheader="false" sidebar="false">
   <apex:dataTable value="{!Account.Contacts}" var="d">
	   <apex:column headerValue="Name" value="{!d.Name}"/>
   </apex:dataTable>
</apex:page>

 

Not ideal but does this work for you?

 

 

All Answers

goabhigogoabhigo

I know it is very easy to do this with apex but I am using PE. So I cannot write apex code. 

So within visualforce code is this achievable?

 

Please suggest.

bob_buzzardbob_buzzard

It looks like this message is coming from whatever code is used to generate the SOQL query from the page.  I've tried various ways to split the reference (using apex:variable or a custom component) but no dice.

 

The only way I could get this to fly was using two separate pages and an apex:iframe.

 

Page 1:

 

 

<apex:page standardController="Opportunity">
   <apex:outputText value="{!Opportunity.Account}" rendered="false" />
   <apex:iframe src="/apex/AggTestPage2?id={!Opportunity.AccountId}" />
</apex:page>

 

Page 2 (named AggTestPage2):

 

 

<apex:page standardController="Account" showheader="false" sidebar="false">
   <apex:dataTable value="{!Account.Contacts}" var="d">
	   <apex:column headerValue="Name" value="{!d.Name}"/>
   </apex:dataTable>
</apex:page>

 

Not ideal but does this work for you?

 

 

This was selected as the best answer
goabhigogoabhigo

You are my champ!! Thanks.

 

Couple of codes........ and it worked like a dream. But you showed me the green flag to start.

 

Thanks again.

GaryRaifeGaryRaife

Hi 

 

I tried the above and it works providng you are rendering as a normal page, however im trying to render the resulting page with the iframe as a PDF.

 

The <apex:iframe> object doesn't work when redering as PDF , so how would one go about displaying the content which is effectively two relationships down from the first page controller using objects which are ok to be rendered as PDF?

 

Thanks


Gary

sparrowbradsparrowbrad
Gary,

I am wondering the same thing - as far as using Bob's suggestion above (it works), but have the resulting page be rendered as a PDF.

I know this post was done 3 years ago, but does anyone know a solution to this?

Thanks!
Maarten LapereMaarten Lapere

This can also be achieved with a component.

On your VF page:

<c:MyComponent myId="{!some.Id}"/>
 

The component:

<apex:component controller="MyController" access="global">
  <apex:attribute name="myId" description="..." type="Id" assignTo="{!objId}"/>
  <apex:repeat var="item" value="{!itemList}>
    {!item.Id} - {!item.Name}
  </apex:repeat>
</apex:component>
 

The controller:

public with sharing class MyController {

  public Id objId {get; set;}

  public Item__c[] getItemList() {
    return [SELECT Id, Name FROM Item__c WHERE Foreign_Key__c = :objId];
  }

}
CG1000CG1000
wow! I have the above solution working on a Visualforce Page on the Case Level. It goes up one level then from there it goes down one level and pulls in related list data.

So here is my issue, and I am desperate for a solution, it works great on a visual force page but I can not figure out how to get it to work on a visualforce email template. The above code requires <apex:page standardController="Case"> which an email template will not accept. Any solution?

CG
Kolade IgeKolade Ige
This worked for me. In my own case I needed it for email template and it worked like a charm.