How to: Filter and Sort a Related List
Use WHERE, ORDER BY, LIMIT, and relationship fields to return only the rows you need.
Goal
<table class="table1">
<thead>
<tr>
<th>Case Number</th>
<th>Subject</th>
<th>Contact</th>
<th>Status</th>
<th>Created</th>
</tr>
</thead>
<tbody><!--{{!
<lineitemsSOQL>
<class>table1</class>
<soql>
SELECT CaseNumber, Subject, Contact.Name, Status, CreatedDate
FROM Case
WHERE AccountId = '{{!Account.Id}}'
AND Status IN ('New', 'Working', 'Escalated')
AND CreatedDate = LAST_90_DAYS
ORDER BY CreatedDate DESC
LIMIT 10
</soql>
<column>CaseNumber</column>
<column>Subject</column>
<column>Contact.Name</column>
<column>Status</column>
<column format-date="MMM d, yyyy">CreatedDate</column>
</lineitemsSOQL>
}}-->
</tbody>
</table>What each clause does
Useful filter patterns
When to use relationship fields
Common fixes
Keep going
Last updated
Was this helpful?

