+ Start a Discussion

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">
    <!-- End Default Content REMOVE THIS -->

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.