For the complete documentation index, see llms.txt. This page is also available as Markdown.

How to: Format and Summarize a Related List

Apply column attributes, conditional output, and aggregate SOQL to make related lists easier to read.

Once your query works, improve the output.

Use attributes to format values, handle blanks, and return cleaner tables.

Format each row

This example formats dates and currency, and replaces empty descriptions.

formatted-related-list.xml
<table class="table1">
  <thead>
    <tr>
      <th>Opportunity</th>
      <th>Stage</th>
      <th>Close Date</th>
      <th>Amount</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Name, StageName, CloseDate, Amount, Description
    FROM Opportunity
    WHERE AccountId = '{{!Account.Id}}'
    ORDER BY CloseDate DESC
    LIMIT 10
  </soql>
  <column>Name</column>
  <column render="RECORD.StageName == 'Closed Won',Won,RECORD.StageName == 'Closed Lost',Lost,RECORD.StageName"></column>
  <column format-date="MMM d, yyyy">CloseDate</column>
  <column prefix="$" format-number="#,###.00">Amount</column>
  <column nullprefix="No description">Description</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>

Build a summary table

Use aggregate SOQL when you need grouped totals instead of row-by-row detail.

Best attributes to use first

  • format-number for currency and numeric output

  • format-date for date and datetime values

  • prefix and postfix for labels and units

  • nullprefix for fallback text

  • substitute for exact value swaps

  • replaceall for partial text cleanup

  • render for row-level logic

  • showcolumn to hide a body column conditionally

  • breakeverynchars for long URLs or IDs

Rules to remember

  • Any field used in render must appear in SELECT

  • Aggregate values should use aliases like dealCount

  • showcolumn hides body cells only

  • Hide the matching header separately when needed

Keep going

Last updated

Was this helpful?