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
B2AB2A 

Visualforce EMAIL template - cannot filter related list

Hi I would like to be able to filter results of a related list in an email template.  Most examples I have seen are for visualforce PAGES, but not email Template.  The syntax seems to be different since it does not work on email template.  Here is the code I have found, although it only applies to VF Pages, rather than email templates:

 

<apex:page Controller="ActivityController" tabstyle="Account">

    <apex:detail subject="{!account}" relatedlist="False">
    </apex:detail>

    <apex:pageBlock title="Activities" >
    <apex:pageBlockSection title="Activities I have access to" columns="1" collapsible="true">
    <apex:dataTable value="{!Activities}" var="each" cellpadding="10" border="0" styleClass="list">
        <apex:column headerValue="Id"><a href="/{!each.Id}">{!each.Id}</a></apex:column>  
    </apex:dataTable>
    </apex:pageBlockSection>
    </apex:pageBlock>

</apex:page>

Any help would be great!!

Thanks

Aiyaz

Ispita_NavatarIspita_Navatar

I came across this example does it serve your purpose somehow:-

 

<messaging:emailTemplate recipientType="Contact"
relatedToType="Account"
105
Integrating Email with Visualforce Creating a Visualforce Email Template
subject="Case report for Account: {!relatedTo.name}"
replyTo="support@acme.com">
<messaging:htmlEmailBody>
<html>
<body>
<p>Dear {!recipient.name},</p>
<p>Below is a list of cases related to {!relatedTo.name}.</p>
<table border="0" >
<tr>
<th>Case Number</th><th>Origin</th>
<th>Creator Email</th><th>Status</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Cases}">
<tr>
<td><a href =
"https://na1.salesforce.com/{!cx.id}">{!cx.CaseNumber}
</a></td>
<td>{!cx.Origin}</td>
<td>{!cx.Contact.email}</td>
<td>{!cx.Status}</td>
</tr>
</apex:repeat>
</table>
<p/>
<center>
<apex:outputLink value="http://www.salesforce.com">
For more detailed information login to Salesforce.com
</apex:outputLink>
</center>
</body>
</html>
</messaging:htmlEmailBody>

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

 

Edwin VijayEdwin Vijay

Hello!

 

I think you cannot filter the related lists in a visualforce email template.

 

Anyhow, try using an

<apex:component>

 

 

inside your visualforce email template. This way you can have a custom controller to do the filtering.

 

Let me know if it works.