function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Neal LightfeldtNeal 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:

User-added image
Best Answer chosen by Neal Lightfeldt
Alain CabonAlain Cabon
Hi,

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

Alain CabonAlain Cabon
Hi,

You should change:  relatedToType="Price_Approval_Details__c"  with relatedToType="Price_Approval__c

  <apex:repeat var="cx" value="{!relatedTo.Price_Approval_Details__r}">
 
This was selected as the best answer
Neal LightfeldtNeal Lightfeldt
Alain,

Oh my gosh. That actually worked. This opens up a whole new world. Thanks very much.