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
Chris TraverChris Traver 

Help with Apex Repeat for Custom Orders Object

Help with Apex Repeat for Custom Orders Object
Hello,

New to Visualforce and creating an email template for orders that have shipped. I'm unable to get the line to repeat if there are multiple items on the same PO #.

Can someone tell me what I'm doing wrong, I keep trying different things and have not been successful.

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Ordered__c"
    subject="Your Order Has Shipped PO # {!RelatedTo.Name}"
    
   
    replyTo="example@example.com">

    <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> Your order or a portion of your order has shipped.  Below shows tracking for each ordered line item</p>
            
            <p> Order #: {!relatedTo.Name}</p>
            
      

            <table>
            <tr>
            <th>Action</th>
            <th>QTY</th>
            <th>Part</th>
            <th>Description</th>
            <th>Tracking</th>
            <th>Freight Co</th>
            </tr>
            
            <apex:repeat var="cx" value="{!relatedTo.id}">
            

            
            <tr>
            <td><a href="https://na1.salesforce.com/{!relatedto.id}">View</a> |
        <a href="https://na1.salesforce.com/{!relatedto.id}/e">Edit</a></td>
            
            
            <td>{!cx.QTY__c}</td>
            <td>{!cx.Part__c}</td>
            <td>{!cx.Description2__c}</td>            
            <td>{!cx.Tracking_Number__c}</td>
            <td>{!cx.Freight_CO__c}</td>
            
            
            </tr>
            </apex:repeat>
            </table>
            
           
            <p> For more information, login to http://www.salesforce.com</p>
            

             
               </font>
            </body>
        </html>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 
Adrian HidalgoAdrian Hidalgo
The value must be a list or array for example:
 
// Apex Code
List<SObject> itemLst = new List<SObject>();

// Visualforce
<apex:repeat var="item" value="{!itemLst}">

You can find more info here: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm​ (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm​" target="_blank)
Chris TraverChris Traver
I guess I don't understand cause that page doesn't come up to anything but a list of guides