Multiple-level Output Lists
You can create multiple-level output lists and multiple-level aggregated output lists using the <advanced_formatting>
tag.
You can traverse five levels in Salesforce using SOQL.
You can include content to be displayed after the data returned by the <advanced_formatting>
in the <after>
tag.
You can include content to be displayed before the data returned by the <advanced_formatting>
in the <before>
tag.
Sample Code
You can display five levels of data where object A has child objects B, C, D and E, where E is a child of D, D is a child of C, C is a child of B and B is a child of A. Object E has an Amount__c field that rolls-up to each level as TotalOfE__c on each level. If the object_name__c field of your template is A and you want to display the five levels of data, you can use something like this:
<output_list object="E" relation="D__r.C__r.B__r.A__c" order_by="D__r.C__r.B__r.A__r.Name, D__r.C__r.B__r.Name, D__r.C__r.Name, D__r.Name, Name" />
You can then add the <advanced_formatting>
tag inside the output list:
<table>
<output_list object=”E” relation=”D__r.C__r.B__r.A__c” order_by=”D__r.C__r.B__r.A__r.Name, D__r.C__r.B__r.Name, D__r.C__r.Name, D__r.Name, Name” >
<advanced_formatting>
<on_change field=”D__r.C__r.B__r.A__c”>
<before><tr><td><ol_field name=”D__r.C__r.B__r.A__r.Name” /></td></tr></before>
<after><tr><td>Total E amount: <ol_field name=”D__r.C__r.B__r.A__r.TotalofE” /></td></tr></after>
</on_change>
<on_change field=”D__r.C__r.B__c”>
<before><tr><td><td><ol_field name=”D__r.C__r.B__r.Name” /></td></td></tr></before>
<after><tr><td><td>Total E amount: <ol_field name=”D__r.C__r.B__r.TotalofE__c” /></td></td></tr></after>
</on_change>
<on_change field=”D__r.C__c”>
<before><tr><td><td><td><ol_field name=”C__r.Name” /></td></td></td></tr></before>
<after><tr><td><td><td>Total E amount: <ol_field name=”D__r.C__r.TotalofE__c” /></td></td></td></tr></after>
</on_change>
<on_change field=”D__c”>
<before><tr><td><td><td><td><ol_field name=”D__r.Name” /></td></td></td></td></tr></before>
<after><tr><td><td><td><td>Total E amount: <ol_field name=”D__r.TotalofE__c” /></td></td></td></td></tr></after>
</on_change>
</advanced_formatting>
<tr>
<td><td><td><td>
<td><ol_field name=”Name”/></td>
<td><ol_field name=”Amount__c”/></td>
</td></td></td></td>
</tr>
</output_list>
</table>