I try to create Visualforce Email Template in order to send our Purchase order (BC) to the supplier So I need to insert inside the mail , all (BC line items ) I begin to create HTML+CSS code , but after with apex , there is an error and I can't find where is it ? after testing with the code below I have this kind of message :
Error: Unknown property 'String.Name'
<messaging:emailTemplate subject="Bon de Commande - Purchase order" recipientType="User" relatedToType="BC_Line_Item__c">
<messaging:plainTextEmailBody >
<html>
<body>
<div id="reference">
<span> - Customer PO : </span> {!relatedTo.BC__c.PO_Number__c}
</div>
<table>
<thead>
<tr>
<th class="desc">Description</th>
<th>Customer Code </th>
</tr>
</thead>
<tbody>
<apex:repeat var="opp" value="{!relatedTo.BC_Line_Item__c}">
<tr>
<td class="desc">'{!opp.Product__c}'</td>
<td class="baan">{!opp.Customer_Number__c}</td>
</tr>
</apex:repeat>
</body>
</html>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
I try to change relatedToType to BC__c instead of BC_Line_Item__c and changing the field but the error is : Error: Invalid field BC_Line_Item__c for SObject BC__c
<messaging:emailTemplate subject="Bon de Commande - Purchase order" recipientType="User" relatedToType="**BC__c**">
<messaging:plainTextEmailBody >
<span> Number : </span> {!relatedTo.Name}
<apex:repeat var="opp" value="{!relatedTo.BC_Line_Item__c}">
<tr>
<td class="desc">'{!opp.Product__c}'</td>
<td class="baan">'{!opp.Customer_Number__c}'</td>
</tr> </apex:repeat>
After checking , there are two Objects : BC and BC_Line_Item Thanks in advance
for more details about the code please Code Source