Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of using <apex:repeat> to return child records in a VF email.
<messaging:emailTemplate subject="Project: [{!relatedTo.Name}] needs Jira key(s)"
<messaging:htmlEmailBody >
<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}
<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>
<apex:repeat var="pt" value="{!relatedTo.AcctSeed__Project_Tasks__r}">
<apex:outputPanel layout="none" rendered="{!pt.Brand_Studio_Product__c}">
<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>
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/>
Industry Dive Accounting
<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} ]
Search the Project Name {!relatedTo.Name} in Salesforce to find the Project &amp; comment in Chatter with the Jira key(s).

This comment has been minimized.

Copy link
Owner Author

@cynthiabellmcgillis cynthiabellmcgillis commented Oct 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment