You need to sign in to do that
Don't have an account?
Russell baker 1
VF email template want to show only last 2 activities related to opportunity
Hi,
I have created a Visual force email template related to opportunity. I want to show last 2 activities realted to opportunity in this email template.
But as per my code it is showing all activities related to opportunty.
How can i restrict number of avtivities show on the page.
here is my code:
<messaging:emailTemplate subject="Stage change reminder" recipientType="User" relatedToType="Opportunity">
<messaging:htmlEmailBody >
<html>
<body>
<h1 style="font-size:100%">
<p>Dear {!recipient.name},</p></h1>
<p>FYI, appended below is a snapshot of the last few activities related to this opportunity:</p>
<table border="3" style="width:100%">
<tr>
<th>View Activity</th>
<th>ActivityDate</th>
<th>Subject</th>
<th>Status</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.ActivityHistories}">
<tr>
<td><a href = "https://ap2.salesforce.com/{!cx.id}">View</a></td>
<td>{!cx.ActivityDate}</td>
<td>{!cx.Subject}</td>
<td>{!cx.Status}</td>
</tr>
</apex:repeat>
</table>
<p> Thank You</p>
<p> Salesforce Team </p>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Plz help me to show only last 2 activities.
Regards
Russell
I have created a Visual force email template related to opportunity. I want to show last 2 activities realted to opportunity in this email template.
But as per my code it is showing all activities related to opportunty.
How can i restrict number of avtivities show on the page.
here is my code:
<messaging:emailTemplate subject="Stage change reminder" recipientType="User" relatedToType="Opportunity">
<messaging:htmlEmailBody >
<html>
<body>
<h1 style="font-size:100%">
<p>Dear {!recipient.name},</p></h1>
<p>FYI, appended below is a snapshot of the last few activities related to this opportunity:</p>
<table border="3" style="width:100%">
<tr>
<th>View Activity</th>
<th>ActivityDate</th>
<th>Subject</th>
<th>Status</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.ActivityHistories}">
<tr>
<td><a href = "https://ap2.salesforce.com/{!cx.id}">View</a></td>
<td>{!cx.ActivityDate}</td>
<td>{!cx.Subject}</td>
<td>{!cx.Status}</td>
</tr>
</apex:repeat>
</table>
<p> Thank You</p>
<p> Salesforce Team </p>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Plz help me to show only last 2 activities.
Regards
Russell
Controller class: Visualforce componant :
and email template:
Regards
Russell
All Answers
There is no standard way to do this, but you can achieve this by using custom controller in visualforce page.
Create a controller.
Component:
Name:OpptyList Now use the componect in template. Something like this.
You need make changes as per your requirment.
Thanks.
Thank you so much for your reply. I'll try this but i got one solution which is working fine for me:
<apex:repeat rows="2" var="cx" value="{!relatedTo.ActivityHistories}">
It is showing last 2 activities in my email template.
Hope if any flaw in this thing you will let me know.
Regards
Russell
when I tried your code it is showing errors.
Please help me out. It's very urgent.
regards
Russell
Controller class: Visualforce componant :
and email template:
Regards
Russell