You need to sign in to do that
Don't have an account?

Related List in VF Email Template
I am new to Visualforce Email Templates so any help is greatly appreciated! Thanks!
I have an email template that I want to fire off of a custom object (Policy__c) but I want to pull in the Related List that appears on the Policy object - the Related List is called Claims. Below is the code I have but the error I keep getting is:
Error: Invalid field Claims__r for SObject Policy__c
<messaging:emailTemplate subject="90 Day Policy Expiration: {!relatedTo.name}" recipientType="Contact" relatedToType="Policy__c">
<messaging:plainTextEmailBody >
The following policy has an Expiration Date that is within 90 days from today.
Details:
Policy: {!relatedTo.Name}
Insured: {!relatedTo.Insured__c}
Effective Date: {!relatedTo.Effective_Date__c}
Expiration Date: {!relatedTo.Expiration_Date__c}
Underwriter: {!relatedTo.Underwriter__c}
Underwriting Branch Office: {!relatedTo.Underwriting_Branch_Office__c}
RELATED CLAIMS:
<apex:repeat value="{!relatedTo.Claims__r}">
</apex:repeat>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
I was able to get help from Support on this one and got to a really great solution so I thought I would share the code that worked and produced a great table showing all the records that appeared in the related list.
<messaging:emailTemplate subject="90 Day Policy Expiration Notification: {!relatedTo.name} - {!relatedTo.Insured__r.name}" recipientType="Contact" relatedToType="Policy__c">
<messaging:htmlEmailBody >
<html>
<body>
<p> Dear {!relatedTo.Underwriter__r.name},</p>
<p>Below is information pertaining to a policy that has an Expiration Date that is within 90 days from today. If you require additional information, please respond to this email and you will be directed appropriately. </p>
<p>Thank you</p>
<p>
</p>
<p>POLICY DETAILS:</p>
<p>Policy: {!relatedTo.Name}
<p>Insured: {!relatedTo.Insured__r.name}
<p>Effective Date: <apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!relatedTo.Effective_Date__c}"/></apex:outputText>
<p>Expiration Date: <apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!relatedTo.Expiration_Date__c}"/></apex:outputText>
<p>Underwriter: {!relatedTo.Underwriter__r.name}
<p>Underwriting Branch Office: {!relatedTo.Underwriting_Branch_Office__c}
</p></p></p></p></p></p>
<p>
</p>
<p>RELATED CLAIMS:</p>
<table border="1">
<tr>
<th>Claim Number</th>
<th>Insured</th>
<th>Claimant Name</th>
<th>Policy Number</th>
<th>Claim Status</th>
<th>Date Reported</th>
<th>Examiner</th>
</tr>
<apex:repeat var="rc" value="{!relatedTo.Claims1__r}">
<tr>
<td>{!rc.Name} </td>
<td>{!rc.Insured_Lookup__r.name}</td>
<td>{!rc.Claimant_Name__c}</td>
<td>{!rc.Policy__r.name}</td>
<td>{!rc.Status__c}</td>
<td><apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!rc.Date_Reported__c}"/></apex:outputText></td>
<td>{!rc.Assigned_Examiner2__r.name}</td>
</tr>
</apex:repeat>
</table>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>