Example of using <apex:repeat> to return child records in a VF email.
<messaging:emailTemplate subject="Project: [{!relatedTo.Name}] needs Jira key(s)" | |
recipientType="User" | |
replyTo="email123@industrydive.com" | |
relatedToType="AcctSeed__Project__c"> | |
<messaging:htmlEmailBody > | |
<html> | |
<body> | |
<STYLE type="text/css"> | |
TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1; text-align: center } | |
TD {font-size: 11px; font-face: verdana } | |
TABLE {border: solid #CCCCCC; border-width: 1} | |
TR {border: solid #CCCCCC; border-width: 1} | |
</STYLE> | |
<font face="arial" size="2"> | |
<p>Hey {!$User.FirstName},</p> | |
<p>Below are the Brand Studio product(s) related to {!relatedTo.AcctSeed__Account__r.Name}'s campaign. </p> | |
<table border="0" > | |
<tr > | |
<th>Project Task Name</th> | |
<th>Product Name</th> | |
<th>Start Date</th> | |
</tr> | |
<apex:repeat var="pt" value="{!relatedTo.AcctSeed__Project_Tasks__r}"> | |
<apex:outputPanel layout="none" rendered="{!pt.Brand_Studio_Product__c}"> | |
<tr> | |
<td> <apex:outPutText value="{!pt.Name}"/></td> | |
<td> <apex:outputtext value="{!pt.Product__r.Name}"/></td> | |
<td> <apex:outputText value="{0, date, MM-dd-yyy}"> <apex:Param value="{!pt.AcctSeed__Start_Date__c}"/> </apex:outputText> </td> | |
</tr> | |
</apex:outputPanel> | |
</apex:repeat> | |
</table> | |
<p> | |
Click on the link to access the record and comment with Jira key(s) for Brand Studio products in Chatter: | |
<apex:outputlink value="{!LEFT($Api.Partner_Server_URL_140,FIND('.com',$Api.Partner_Server_URL_140)+4)+relatedTo.Id}">{!relatedTo.Name}<br/> <br/> <br/> | |
</apex:outputlink> | |
Thanks,<br/> | |
Industry Dive Accounting | |
</p> | |
<p/> | |
<p/> | |
</font> | |
</body> | |
</html> | |
</messaging:htmlEmailBody> | |
<messaging:plainTextEmailBody > | |
Hey {!$User.FirstName}, | |
Below are the Brand Studio product(s) related to {!relatedTo.AcctSeed__Account__r.Name}'s campaign. | |
[ Project Task Name ] - [Product Name ] - [ Start Date ] | |
------------------------------------------------------------------------- | |
<apex:repeat var="pt" value="{!relatedTo.AcctSeed__Project_Tasks__r}"> | |
[ {!pt.Name} ] - [ {!pt.Product__r.Name} ] - [ {!pt.AcctSeed__Start_Date__c} ] | |
</apex:repeat> | |
Search the Project Name {!relatedTo.Name} in Salesforce to find the Project & comment in Chatter with the Jira key(s). | |
</messaging:plainTextEmailBody> | |
</messaging:emailTemplate> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Note: This is not HTML, this is Visualforce! But I named the file extension .html because .vfp did not highlight anything and make it hard to read.