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

Related List Working Examples

Each example below uses the standard related list structure:

  • <!--{{! and }}-->

  • <lineitemsSOQL>

  • <class>

  • <soql>

  • <column>

1

Aggregate Query: Summing Totals by Account

This groups Opportunities by Account and sums the related amounts.

<table class="table1">
  <thead>
    <tr>
      <th>Account</th>
      <th>Total Amount</th>
      <th>Opportunity Count</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Account.Name, SUM(Amount) total, COUNT(Id) qty
    FROM Opportunity
    WHERE AccountId != null
    GROUP BY Account.Name
    ORDER BY SUM(Amount) DESC
    LIMIT 10
  </soql>
  <column>Account.Name</column>
  <column format-number="$#,###.00">total</column>
  <column postfix=" deals">qty</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
2

Three-Level Parent Traversal

This traverses three parent levels: Case → Contact → Account → Owner.

<table class="table1">
  <thead>
    <tr>
      <th>Case Number</th>
      <th>Contact</th>
      <th>Account</th>
      <th>Account Owner</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT CaseNumber, Contact.Name, Contact.Account.Name, Contact.Account.Owner.Name
    FROM Case
    WHERE Status != 'Closed'
    LIMIT 15
  </soql>
  <column>CaseNumber</column>
  <column>Contact.Name</column>
  <column>Contact.Account.Name</column>
  <column>Contact.Account.Owner.Name</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
3

Date Literals & Status Badging

This uses a SOQL date literal and the render attribute for status output.

<table class="table1">
  <thead>
    <tr>
      <th>Opportunity</th>
      <th>Stage</th>
      <th>Close Date</th>
      <th>Amount</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Name, StageName, CloseDate, Amount
    FROM Opportunity
    WHERE CloseDate = LAST_90_DAYS AND Amount > 0
  </soql>
  <column>Name</column>
  <column type="rtf" render="RECORD.StageName == 'Closed Won', lt#span style='color:green; font-weight:bold;'gt#WONlt#/spangt#, RECORD.StageName == 'Closed Lost', lt#span style='color:red; font-weight:bold;'gt#LOSTlt#/spangt#, RECORD.StageName"></column>
  <column format-date="MMM d, yyyy">CloseDate</column>
  <column format-number="$#,###.00">Amount</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
4

Polymorphic Fields (Owner)

This pulls task owner data and highlights high-priority tasks.

<table class="table1">
  <thead>
    <tr>
      <th>Priority Flag</th>
      <th>Subject</th>
      <th>Owner</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Subject, Priority, Owner.Name
    FROM Task
    WHERE Status != 'Completed'
    ORDER BY Priority DESC
  </soql>
  <column render="RECORD.Priority == 'High', URGENT, RECORD.Priority"></column>
  <column>Subject</column>
  <column>Owner.Name</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
5

Complex Filtering with OR/AND Logic

This uses grouped OR and AND conditions in the WHERE clause.

<table class="table1">
  <thead>
    <tr>
      <th>Account</th>
      <th>Industry</th>
      <th>Annual Revenue</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Name, Industry, AnnualRevenue
    FROM Account
    WHERE (BillingState = 'CA' OR BillingState = 'NY')
      AND (Type = 'Customer - Direct' OR Type = 'Customer - Channel')
      AND AnnualRevenue > 1000000
  </soql>
  <column>Name</column>
  <column>Industry</column>
  <column format-number="$#,###">AnnualRevenue</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
6

Merging & Cleaning Contact Info

This combines mergenext, substitute, prefix, and postfix.

<table class="table1">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Title</th>
      <th>Department</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>SELECT FirstName, LastName, Title, Department FROM Contact</soql>
  <column mergenext="true" postfix=" ">FirstName</column>
  <column>LastName</column>
  <column substitute="VP, Vice President, Dir, Director">Title</column>
  <column prefix="(" postfix=")">Department</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
7

"Top N" Records with Null Handling

This returns the top 5 Opportunities by amount and handles null descriptions.

<table class="table1">
  <thead>
    <tr>
      <th>Opportunity</th>
      <th>Amount</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Name, Amount, Description
    FROM Opportunity
    WHERE Amount != null
    ORDER BY Amount DESC
    LIMIT 5
  </soql>
  <column>Name</column>
  <column format-number="$#,###">Amount</column>
  <column nullprefix="Standard Deal">Description</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
8

Conditional Visibility based on Parent Field

This uses a parent merge field in showcolumn.

This example assumes the template runs from an Opportunity record.

<table class="table1">
  <thead>
    <tr>
      <th>Product</th>
      <th>Quantity</th>
      <!--RENDER='{{!Opportunity.Account.Rating}}' != 'Hot' --><th>Discount</th><!--ENDRENDER-->
      <th>Total Price</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Name, Quantity, Discount__c, TotalPrice
    FROM OpportunityLineItem
    WHERE OpportunityId = '{{!Opportunity.Id}}'
  </soql>
  <column>Name</column>
  <column>Quantity</column>
  <column showcolumn="{{!Opportunity.Account.Rating}} != 'Hot'">Discount__c</column>
  <column format-number="$#,###.00">TotalPrice</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
9

Long Text Handling in Descriptions

This strips markup and forces line breaks inside long text values.

<table class="table1">
  <thead>
    <tr>
      <th>Product</th>
      <th>Product Code</th>
      <th>Custom URL</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>
    SELECT Name, ProductCode, CustomURL
    FROM Product2
    WHERE IsActive = true
  </soql>
  <column>Name</column>
  <column>ProductCode</column>
  <column type="text" breakeverynchars="30">CustomURL</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
10

Replacing Partial Text Strings

This uses replaceall to swap internal codes with user-facing text.

<table class="table1">
  <thead>
    <tr>
      <th>Case</th>
      <th>Comments</th>
    </tr>
  </thead>
  <tbody><!--{{!
<lineitemsSOQL>
  <class>table1</class>
  <soql>SELECT Name, Comments__c FROM Case</soql>
  <column>Name</column>
  <column replaceall="ERR-001, System Error, WRN-002, Warning">Comments__c</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>

Last updated

Was this helpful?