Hi SalesForce Community.
I am hoping you can help,I have encountered different issues with my email template, and i have searched different forums and getting my self more and more confused. To give some context I am trying to Create a VF email template that returns fields from the related list on the sales_and_marketing__c object.
I have three objects in question (See Two images attached) sales_and_marketing__c, Material_Records__c, Materials_Junction__c
When on the sales_and_marketing__c object there is a related list. When you scroll down to the related list and click on new it opens up a pop up box which is the Materials_Junction__c.
Materials_Junction__c object has three fields (see Material Junction photo)
When you click on the magnifying class on "Material record" fields you are presenting with the following. this is the Material_Records__c object.
After selecting your materials you will return to this screen(See below) you add in a quantity amount and press save
Once you push "save" the materials you have selected along with quantity will be presented on the sales_marketing object (as seen below)
On my email template i should see.
Name of "Sales and Marketing" Record ( so example above it would be "Test") Then 5 lines to show the products, item , quantity
Recap : Products and Item comes from the Material_Records__c object, and quantity from the Materials_Junction__c object
This is my attempt at my VF Page
<messaging:emailTemplate recipientType="Contact"
relatedToType="sales_and_marketing__c"
subject="Testing VF page: {!relatedTo.name}">
<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 materials related to : {!relatedTo.name}.</p>
<table border="0" >
<tr >
<th>Action</th><th>Case Number</th><th>Subject</th><th>Creator Email</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.Materials_Junction__r}">
<tr>
<td><a href="https://na1.salesforce.com/{!cx.Materials_Record__c}">View</a> |
<a href="https://na1.salesforce.com/{!cx.Materials_Record__c}/e">Edit</a></td>
<td>{!cx.Materials_Record__r.Product__c}</td>
<td>{!cx.Materials_Record__r.Active__c}</td>
<td>{!cx.Materials_Record__r.Item__c}</td>
</tr>
</apex:repeat>
</table>
<p />
</font>
</body>
</html>
</messaging:htmlEmailBody>
<messaging:plainTextEmailBody>
Dear {!recipient.name},
Below is a list of cases related to Account: {!relatedTo.name}
[ product ] - [ active ] - [ Itemss]
<apex:repeat var="cx" value="{!relatedTo.Materials_Junction__r}">
[ {!cx.Materials_Record__r.Product__c} ] - [ {!cx.Materials_Record__r.Active__c} ] - [{!cx.Materials_Record__r.Item__c} ]
</apex:repeat>
For more information login to http://www.salesforce.com
</messaging:plainTextEmailBody>
</messaging:emailTemplate>