You need to sign in to do that
Don't have an account?
Creating a Visualforce Template For Task
I am try to create a visualforce template to display all the task that a user(s) may have open the following day, but I am receiving this error inside salesforce when I save my code. Here is the error message:
Error: Invalid field Task for SObject Task |
Can some body please help me, and tell me where I am going wrong in visualforce. Thanks, also below is my visualforce code:
<messaging:emailTemplate subject="Task For Today" recipientType="User" relatedToType="Task">
<messaging:htmlEmailBody>
<html>
<style type="text/css">
body{font-family: Courier; size: 12pt;}
table{
border-width: 5px;
border-spacing: 5px;
border-style: line;
border-color: #FF0000;
background-color: #FFFFFF;
}
td {
border-width: 1px;
padding: 4px;
border-style: solid;
border-color: #000000;
background-color: #FFEECC;
}
th {
color: #000000;
border-width: 1px ;
padding: 4px ;
border-style: solid ;
border-color: #000000;
background-color: #FFFFF0;
}
</style>
<body>
<p>Dear {!recipient.name},<br />
Below is a list of task(s) that are assign to you, for today!
</p>
<table border="0" >
<tr>
<th>Subject</th><th>Name of Lead</th>
<th>Name of Contact</th><th>Phone #</th>
<th>Lead's Email</th><th>Contact Email</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Task}">
<tr>
<td>{!cx.Subject}</td>
<td>{!cx.Lead.Name}</td>
<td>{!cx.Contact.Name}</td>
<td>{!cx.Phone}</td>
<td>{!cx.Lead.email}</td>
<td>{!cx.Contact.email}</td>
</tr>
</apex:repeat>
</table>
</body>
</html>
</messaging:htmlEmailBody></messaging:emailTemplate>
Hi,
The try removing /comment the following fields referred by you:-
<td>{!cx.Lead.Name}</td>
<td>{!cx.Contact.Name}</td>
<td>{!cx.Lead.email}</td>
<td>{!cx.Contact.email}</td>
and check if the error persists , if the error goes away let me know , then I will tell you the reason ....
I saw your relatedToType is Task and you are referencing relatedTo.Task, means it is "Task.Task", that obviously does not mean anything.
But yes I have tried it by changing the RelatedToTYpe from Task to User, and then in repeat , I referenced relatedTo.Tasks , it is also not working, there must be some gotcha.
Hey hemantgarg,
I am thinking the same thing. I am starting to believe that we are not able to create user custom templates, that templates can only target leads and contacts; that templates are not used for internal people like users.
Thanks,
WH