You need to sign in to do that
Don't have an account?
Neal Lightfeldt
Trying to create VisualForce email template
I'm trying to create a VF email template that will display line items from a related list. I am completely new to VF and although I've got the basics right below, I know I'm missing a few things.
I have two custom objects. "Price_Approval__c" is the parent, "Price_Approval_Details__c" is the child (screenshot below).
Below is VF markup (basically stolen from elsewhere). I have traveled various forums/help files and still feel no closer to making this work:
<messaging:emailTemplate subject="New price request approval required" recipientType="Contact"
relatedToType="Price_Approval_Details__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>Dear {!recipient.name},</p>
<p>Below is a list of line items included in this Price Approval Request: {!relatedTo.name}.</p>
<table border="0" >
<tr >
<th>Action</th><th>Part No</th><th>List Price</th><th>Sell Price</th><th>Margin</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Price_Approval__c.Price_Approval_Details__r}">
<tr>
<td><a href="https://cs78.salesforce.com/{!cx.id}">View</a> |
<a href="https://cs78.salesforce.com/{!cx.id}/e">Edit</a></td>
<td>{!cx.Part_No__c}</td>
<td>{!cx.List_Price__c}</td>
<td>{!cx.Sell_Price__c}</td>
<td>{!cx.Margin__c}</td>
</tr>
</apex:repeat>
</table>
<p />
</font>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Here is the actual page:
I have two custom objects. "Price_Approval__c" is the parent, "Price_Approval_Details__c" is the child (screenshot below).
Below is VF markup (basically stolen from elsewhere). I have traveled various forums/help files and still feel no closer to making this work:
<messaging:emailTemplate subject="New price request approval required" recipientType="Contact"
relatedToType="Price_Approval_Details__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>Dear {!recipient.name},</p>
<p>Below is a list of line items included in this Price Approval Request: {!relatedTo.name}.</p>
<table border="0" >
<tr >
<th>Action</th><th>Part No</th><th>List Price</th><th>Sell Price</th><th>Margin</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Price_Approval__c.Price_Approval_Details__r}">
<tr>
<td><a href="https://cs78.salesforce.com/{!cx.id}">View</a> |
<a href="https://cs78.salesforce.com/{!cx.id}/e">Edit</a></td>
<td>{!cx.Part_No__c}</td>
<td>{!cx.List_Price__c}</td>
<td>{!cx.Sell_Price__c}</td>
<td>{!cx.Margin__c}</td>
</tr>
</apex:repeat>
</table>
<p />
</font>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Here is the actual page:
You should change: relatedToType="Price_Approval_Details__c" with relatedToType="Price_Approval__c"
<apex:repeat var="cx" value="{!relatedTo.Price_Approval_Details__r}">
All Answers
You should change: relatedToType="Price_Approval_Details__c" with relatedToType="Price_Approval__c"
<apex:repeat var="cx" value="{!relatedTo.Price_Approval_Details__r}">
Oh my gosh. That actually worked. This opens up a whole new world. Thanks very much.