Sometimes you need to send email alert which should include related list details also. You can achieve this type of alert by using the visual force email type template in Fieldax&Field Service Management. The below example to explain visual force email template.
For example, the Class Staff (Tutor) need to know the student information and his subject details.
Create New Template :–
Goto – Setup -> Administer -> Communication Templates -> Email Templates -> New Template
Then select visual force template format and enter the below code and click save.
Try the below code –
<messaging:emailTemplate subject=”Student and related Subjects” recipientType=”User” relatedToType=”Student__c” >
<messaging:htmlEmailBody>
Dear <b>{!recipient.Name}</b>,
The student <b>{!relatedTo.Name}</b> allocated in your our class. Kindly take care.
<p>Student Details</p>
<table>
<tr><th>Name</th><th>Address</th><th>Marks</th>
<th>Name</th><th>Address</th><th>Marks</th>
</tr>
<apex:repeat value=”{!relatedTo}” var=”s”>
<tr>
<td>{!s.Name}</td><td>{!s.Address__c}</td><td>{!s.Marks__c}</td>
</tr>
</apex:repeat></table>
</table>
<p>Subjects Details</p>
<table>
<tr><th>Student Name</th><th>Subject-1</th><th>Subject-2</th><th>Subject-3</th></tr>
<apex:repeat value=”{!relatedTo.Subject__r}” var=”v”>
<tr>
<td>{!v.Name}</td><td>{!v.sub1}</td><td>{!v.sub2}</td><td>{!v.sub3}</td>
</tr>
</apex:repeat>
</table>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Note:
relatedToType – This is specified object which one details you want to send.
messaging:htmlEmailBody – This tag is used for you can include HTML tags inside it otherwise you can use ‘messaging:plainTextEmailBody’ tag.
{!relatedTo.Name} – This is refer student object
{!relatedTo.Subject__r} – This is referred student object related object contains double underscore with r.
We are the ISV Partners and Please reach us for custom development => www.merfantz.com
—————————— We hope it will help to you ——————————