+ Start a Discussion

Visual Force Email Template Opportunity, OpportunityLineItems, Product


I am trying to create an e-mail template to send contacts an e-mail about product information using a visual force page.


I can send them the information such as the Product ID, the Quantity and the last date it was modified, but I can't send them the product 'NAME' as the name is not stored int he OpportunityLineItems Object


Is there a way to insert a join between OpportunityLineItems and Product2 based off the PricebookentryID to show insert the Product Name next to the Database ID?


Below is my code


Thank you



<messaging:emailTemplate subject="pd2" recipientType="Contact" relatedToType="Opportunity">
<messaging:HtmlEmailBody >
<table border="0">
     <th>Last Modified Date</th>
<apex:repeat var="cx" value="{!relatedTo.OpportunityLineItems}">
        <a href="https://na4.salesforce.com/{!cx.id}">{!cx.Description} </a>

<messaging:emailTemplate subject="pd2" recipientType="Contact" relatedToType="Opportunity"><messaging:HtmlEmailBody ><center><table border="0">

 <tr>     <th>Product</th>     <th>Quantity</th>     <th>Last Modified Date</th>

<apex:repeat var="cx" value="{!relatedTo.OpportunityLineItems}"><tr>    <td>        <a href="https://na4.salesforce.com/{!cx.id}">{!cx.Description} </a>    </td></tr>     <td>{!cx.PRICEBOOKENTRYID}</td>     <td>{!cx.Quantity}</td>     <td>{!cx.LastModifiedDate}</td>
</tr>     </apex:repeat>




You can use a component in your Visualforce Template. Then do all your business logic in your controller class..

Check here I have explained with opportunities. http://salesforcetrekbin.blogspot.com/2010/05/visualforce-email-template-with.html


'Hope this helps