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
src0010src0010 

Visualforce Email Template: Cannot get related list to display on rendered PDF

Hi,
 
I am working on a Visualforce email template that pulls data from a custom object and renders to PDF.  I was able to get everything working and the regular 'outputField' data appears on the rendered PDF without any issues.  However, I am trying to get related lists on the custom object to display on the PDF and not having any success so far.   
 
 Below is a copy of my Visualforce email template (related list I am trying to call is highlighted in red):

<messaging:emailTemplate subject="Your requested quote #{!relatedTo.Name}" recipientType="Contact" relatedToType="X360_Contract_Cycle__c"> <messaging:plainTextEmailBody > Dear {!recipient.name}, Thank you for your continued interest in our offering. Please see the attached quote per your request. Feel free to contact me if you have any questions. Regards, {!$User.firstname} {!$User.lastname} </messaging:plainTextEmailBody> <messaging:attachment renderAs="pdf" filename="{!relatedTo.name}"> <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:panelGrid columns="1" styleClass="centered" width="100%"> <apex:outputText value="Quote# {!relatedTo.Name}" /> Start Date: <apex:outputField value="{!relatedTo.Start_Date__c}" /> End Date: <apex:outputField value="{!relatedTo.End_Date__c}" /> Contracted Development Service Hours: <apex:outputField value="{!relatedTo.Contracted_Development_Service_Hours__c}" /> Delivered Development Service Hours: <apex:outputField value="{!relatedTo.Delivered_Hours__c}" /> . . . <apex:relatedList list="Cases__r"/> </apex:panelGrid> </messaging:attachment></messaging:emailTemplate>

 

WSDL for the 'X360_Contract_Cycle__c' custom object I am calling is below (the related list element in question is highlighted in red...note this is a lookup relation from Case to X360_Contract_Cycle__c) :

 

 

<complexType name="X360_Contract_Cycle__c"> <complexContent> <extension base="ens:sObject"> <sequence> <element name="Account__c" nillable="true" minOccurs="0" type="tns:ID"/> <element name="Account__r" nillable="true" minOccurs="0" type="ens:Account"/> <element name="ActivityHistories" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="Attachments" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="Cases__r" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="Contracted_Audits__c" nillable="true" minOccurs="0" type="xsd:double"/> <element name="Contracted_Development_Service_Hours__c" nillable="true" minOccurs="0" type="xsd:double"/> <element name="Contracted_Oxygen_Licenses__c" nillable="true" minOccurs="0" type="xsd:double"/> <element name="Contracted_Training_Seats__c" nillable="true" minOccurs="0" type="xsd:double"/> <element name="CreatedBy" nillable="true" minOccurs="0" type="ens:User"/> <element name="CreatedById" nillable="true" minOccurs="0" type="tns:ID"/> <element name="CreatedDate" nillable="true" minOccurs="0" type="xsd:dateTime"/> <element name="Delivered_Audits__c" nillable="true" minOccurs="0" type="xsd:double"/> <element name="Delivered_Hours__c" nillable="true" minOccurs="0" type="xsd:double"/> <element name="Delivered_Oxygen_Licenses__c" nillable="true" minOccurs="0" type="xsd:double"/> <element name="End_Date__c" nillable="true" minOccurs="0" type="xsd:date"/> <element name="Events" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="Histories" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="IsDeleted" nillable="true" minOccurs="0" type="xsd:boolean"/> <element name="LastActivityDate" nillable="true" minOccurs="0" type="xsd:date"/> <element name="LastModifiedBy" nillable="true" minOccurs="0" type="ens:User"/> <element name="LastModifiedById" nillable="true" minOccurs="0" type="tns:ID"/> <element name="LastModifiedDate" nillable="true" minOccurs="0" type="xsd:dateTime"/> <element name="Name" nillable="true" minOccurs="0" type="xsd:string"/> <element name="Notes" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="NotesAndAttachments" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="OpenActivities" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="Owner" nillable="true" minOccurs="0" type="ens:Name"/> <element name="OwnerId" nillable="true" minOccurs="0" type="tns:ID"/> <element name="Oxygen_License_Request__r" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="ProcessInstances" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="ProcessSteps" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="Site_Audit__r" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="Start_Date__c" nillable="true" minOccurs="0" type="xsd:date"/> <element name="SystemModstamp" nillable="true" minOccurs="0" type="xsd:dateTime"/> <element name="Tasks" nillable="true" minOccurs="0" type="tns:QueryResult"/> <element name="Training_Attended__c" nillable="true" minOccurs="0" type="xsd:double"/> <element name="Training_Attendee__r" nillable="true" minOccurs="0" type="tns:QueryResult"/> </sequence> </extension> </complexContent> </complexType>

 

 

 

 Any suggestions on what I am doing wrong?  Thanks!
Best Answer chosen by Admin (Salesforce Developers) 
src0010src0010

In case it helps anyone down the road I had to end up using a apex:repeat statement instead of <apex:relatedList list="Cases__r"/> to pull in the related list items on the PDF.

 

All Answers

src0010src0010
Sorry, the code format got mangled when I posted.  If it is to hard to read and helps I can try to post the code another way...just let me know.  Thanks in advance!
src0010src0010

In case it helps anyone down the road I had to end up using a apex:repeat statement instead of <apex:relatedList list="Cases__r"/> to pull in the related list items on the PDF.

 

This was selected as the best answer