You need to sign in to do that
Don't have an account?
Shaun123
Aggregate relationships??? unsure which apex methods and structure access to use
Hi all
I'm new to SF using apex code.
What's the way to access/join objects and obtain the custom fields?
Contracts
|
Clients
|
Campaigns (Trying to access this object and custom field values from the Contracts object - top down approach)
Thanks
Shaun
I need to access the Campaigns from the Contracts object instead :p
Quick Test to show that this compiles, but it's under the Adwords Client Object works:
<messaging:emailTemplate subject="Adwords Campaign Performace Report" recipientType="Contact" relatedToType="Adwords_Client__c">
<messaging:plainTextEmailBody>
</messaging:plainTextEmailBody>
<messaging:attachment renderAs="PDF" filename="Adwords Campaign Performace Report.pdf">
<html>
<body>
<apex:repeat var="item" value="{!relatedTo.Adwords_Campaigns__r}">
</apex:repeat>
</body>
</html>
</messaging:attachment>
</messaging:emailTemplate>
works:
<messaging:emailTemplate subject="Adwords Campaign Performace Report" recipientType="Contact" relatedToType="Adwords_Contract__c">
<messaging:plainTextEmailBody>
</messaging:plainTextEmailBody>
<messaging:attachment renderAs="PDF" filename="Adwords Campaign Performace Report.pdf">
<html>
<body>
<apex:repeat var="item" value="{!relatedTo.Adwords_Client__r}">
</apex:repeat>
</body>
</html>
</messaging:attachment>
</messaging:emailTemplate>
doesn't work:
"Error: Aggregate Relationship is used in an unsupported complex expression containing 'Adwords_Client__r.adwords_campaigns__r'"
<messaging:emailTemplate subject="Adwords Campaign Performace Report" recipientType="Contact" relatedToType="Adwords_Contract__c">
<messaging:plainTextEmailBody>
</messaging:plainTextEmailBody>
<messaging:attachment renderAs="PDF" filename="Adwords Campaign Performace Report.pdf">
<html>
<body>
<apex:repeat var="item" value="{!relatedTo.Adwords_Client__r.Adwords_Campaigns__r}">
</apex:repeat>
</body>
</html>
</messaging:attachment>
</messaging:emailTemplate>
I'm guessing I have to create a new field "Adwords_Campaigns__c" Lookup(Adwords Campaigns) under the Adword Client Object and use the
"Adwords_Campaigns__c"?
<messaging:emailTemplate subject="Adwords Campaign Performace Report" recipientType="Contact" relatedToType="Adwords_Contract__c">
<messaging:plainTextEmailBody>
</messaging:plainTextEmailBody>
<messaging:attachment renderAs="PDF" filename="Adwords Campaign Performace Report.pdf">
<html>
<body>
<apex:repeat var="item" value="{!relatedTo.Adwords_Client__r.Adwords_Campaigns__c}">
</apex:repeat>
</body>
</html>
</messaging:attachment>
</messaging:emailTemplate>
No worries look like I need to use a combination of controllers, components and visualforcetemplate apex code
I have the same issue in visual force email template. Please let me know if you were able to resolve it.
I am trying to access the custom object from Account
Opportunity-> Account-> Custom Object
<messaging:attachment filename="{!relatedTo.Account.name} {!relatedTo.name}- UpdateSummary.csv" >
<apex:repeat var="cx" value="{!relatedTo.Account.CustomObject__r}" >
</apex:repeat>
</messaging:attachment>
I am getting an error as,
Aggregate Relationship is used in an unsupported complex expression containing 'Account.CustomObject__r'
Any help would be greatly appreciated.
thanks