I have created visualforce email template for Task Object. Email pops up to the respective user Id when sent through 'Send test and verify merge fields' with content specified in template. And when the same vf email template when called from workflow for Task email pops up but with empty content. Please guide me. Thanks
The code below is the Visualforce email template created. On creating workflow for Task object with email alert, email gets popped up but with no content.
<messaging:emailTemplate subject="AOO"
recipientType="User"
relatedToType="Contact">
<messaging:htmlEmailBody >
<html>
<body>
<style>
hr {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
border-color: blue;
}
table {
font-family: Times New Roman, sans-serif;
border-collapse: collapse;
width: 75%;
}
td, th {
border-bottom: 1px solid #ddd;
text-align: left;
padding: 8px;
}
</style>
<table>
<apex:repeat var="vt" value="{!relatedTo.Tasks}">
<tr>
<td><b>AssignedTo</b></td>
<td>{!vt.Owner.name}</td>
<td><b>Status</b></td>
<td>{!vt.Status}</td>
</tr>
<tr>
<td><b>Subject</b></td>
<td>'{!vt.Subject}'</td>
<td><b>Name</b></td>
<td>'{!vt.who.Name}'</td>
</tr>
<tr>
<td><b>Due date</b></td>
<td>{!vt.ActivityDate}</td>
<td><b>RelatedTo</b></td>
<td>{!vt.What.Name}</td>
</tr>
<tr>
<td><b>Phone</b></td>
<td>9066846020</td>
<td><b>Email</b></td>
<td>chandanakk1995@gmail.com</td>
</tr>
<tr>
<td><b>CreatedBy</b></td>
<td>{!vt.CreatedBy.Name}</td>
<td><b>Last ModifiedBy</b></td>
<td>{!vt.LastModifiedBy.Name}</td>
</tr>
<tr>
<td><b>Comments</b></td>
<td>{!vt.Description}</td>
</tr>
</apex:repeat>
</table>
<table>
<apex:repeat var="bt" value="{!relatedTo.Tasks}">
<tr>
<td>
Remainder <input type="checkbox" name="Remainder" /></td>
<td>{!bt.IsReminderSet}</td>
</tr>
</apex:repeat>
</table>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Best Answer
There is a known issue with VF email templates and WFR that can cause these kinds of issues, https://success.salesforce.com/issues_view?id=a1p30000000SdBfAAK Recipient bind values are blank. The work around is either get all the data you need from the RelatedTo value or else use a trigger instead of WFR.