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
dl-1dl-1 

Apex Repeat on object

I'm trying to do a very simple repleat on an object.  I've looked at several examples and so far I've been unable to figure it out.

 

To help me learn this platform I'm creating a very simple expense report.  The report is Expense_Report__c and it can contain the objects Expense_Item_c.  This is working great.

 

Now I'm trying to figure out how to generate a PDF that will show me the name of the expense report and list the expense items related to that expense report.

 

I've looked a several examples but can't quite figure out what seems like is pretty straight forward.

 

Here's my code:

 

<apex:page standardController="Expense_Report__c" showHeader="false" renderAs="pdf">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>XX 2:<apex:outputText value="{!Expense_Report__c.Name}" /></h1>
 
  <apex:repeat var="item" value="{!Expense_Report__c.Expense_Item__r">
  <tr><td>item.name</td></tr>
  </apex:repeat>
    <!-- End Default Content REMOVE THIS -->
</apex:page>

OnDem DevOnDem Dev

Are you using item.name or {!item.name}.

If not using {!item.name}, please do that.

Also ensure that you use apex:outputText ot outputLabel to avoid XSS.