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
RDM1961RDM1961 

Visual Force email template - error calling related object

 

I'm attempting my first visualforce email template (actually my first visual force anything).  We have a custom object "Customer_Support__c" which has a child object "CS_Product__c". When I try to reference the child object to insert a table of related records I get the error ErrorError: Invalid field CS_Product__c for SObject Customer_Support__c.

 

Code is below. Any guidance on where I've gone wrong would be greatly appreciated.

 

Thanks,

Rick


 

 

<messaging:emailTemplate subject="subject" 
      recipientType="User" 
      relatedToType="Customer_Support__c"
      replyTo="Richard.Methe@company.com">
<messaging:htmlEmailBody >
      <p> Dear {!relatedTo.Contact__c},</p>
      <p> Company has received communication regarding the event described below and we have logged this within our complaint system. If you have any questions or have any further information regarding this event, please contact us either  by calling (999) 999-9999 ext. 2205 or send an email to our Customer Affairs team in xxx at CustomerAffairs@Company.com.</p> 
    <p>Replacement Product is shipping on Sales Order number {!RelatedTo.Sales_Order_Number__c}.</p>
    
     <b><u>Complaint Acknowledgement:</u></b>
     <br>Ref #: {!RelatedTo.Name}</br>
     Created by: {!RelatedTo.CreatedBy}
     <br>Account: {!relatedTo.Account__c}</br>
     Communicated via: {!RelatedTo.Communicated_Via__c}
     <br>Date Communicated: {!relatedTo.Date_Communicated__c}</br>
     <p><b>Event Details:</b></p>
     Event Date: {!RelatedTo.Event_Date__c}
     <br>Patient Initials: {!relatedTo.Patient_Initials__c}</br>
     DOB: {!relatedTo.DOB__c}
     <br>Implant Date: {!relatedTo.Implant_Date__c}</br>
    <b>Event Description:</b>
    <br>{!relatedTo.Event_Summary__c}</br>
    <b>Product</b>
<table border="0" >
    <tr>
        <th>Part Number</th><th>Description</th><th>Lot Number</th><th>Serial Number</th>
    </tr>
    <apex:repeat var="cx" value="{!relatedTo.CS_Product__c}">
        <tr>
            <td>{!cx.Part_Number__c}</td>
            <td>{!cx.Description__c}</td>
            <td>{!cx.Lot_Number__c}</td>
            <td>{!cx.Serial_Number__c}</td>
        </tr>
    </apex:repeat>
</table> 
<b>Product Return:</b>
<br>If you have not already done so, please return the product to our {!relatedTo.Return_To__c} facilities at your earliest convenience. Be sure to include the reference number  {!RelatedTo.Name} on the outside of all packages. </br>
<br><b>Address:</b> </br>
Corporation
<br>Returned Product Analysis </br>
2433 4th Avenue
<br>sometown, WI 51803</br> 
(999) 999-9999ext. 2360  
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

 

 

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Alex_ConfigeroAlex_Configero

 

Look at the lookup field that links CS_Product__c to Customer_Support__c under setup. If it's a master-detail relationship you will see a section called "Child Relationship Name" (probably CS_Products)

 

Use that name for the repeat

 

 

 <apex:repeat var="cx" value="{!relatedTo.CS_Products}">

 

That should do it

 

All Answers

Alex_ConfigeroAlex_Configero

 

Look at the lookup field that links CS_Product__c to Customer_Support__c under setup. If it's a master-detail relationship you will see a section called "Child Relationship Name" (probably CS_Products)

 

Use that name for the repeat

 

 

 <apex:repeat var="cx" value="{!relatedTo.CS_Products}">

 

That should do it

 

This was selected as the best answer
RDM1961RDM1961

Thanks Alex,  that did it. Always the little things...

Alex_ConfigeroAlex_Configero

 

No problem. Would you mind marking my answer as the solution?

 

Cheers.