Aggregated Output List

Performs a calculation on a group of filtered data and can return several records grouped by the fields that you specify.

Syntax:

<aggregated_output_list object="Salesforce Object" relation="relationship field" group_by="api_field_name,...">
<filters>
<filter field="api_field_name" operator="equal,less,less_or_equal,greater,greater_or_equal,not_equal" value="value to compare to" />
<filter ... />
<filter ... />

</filters>
<aol_field name="aol_field_name" alias="alias" aggregate_function="Calculation" type="DataType" format="NumberFormat,DateFormat,DateTimeFormat" (for type="DataType") />
</aggregated_output_list>

Where:

  • Salesforce Object is the API name of the object on which to output information from.
  • relationship field is the field to obtain the information from.
  • api_field_name,.. is the field to group the records by.
Note:

If you want a total of all records in a single row, you can leave group_by blank like this: group_by="".

You can add <filter> tags to filter the information returned by the <aggregated_output_list> tag.

If your template contains an <aggregated_output_list> tag, that tag must contain at least one <aol_field> tag. Where:

  • aol_field_name is the API name of a field in the aggregated output list to display in the output.
  • alias is an optional ID that you can assign if you want to carry out further processing on the data generated by the aggregated_output_list tag.
  • Calculation is the calculation to perform on the data. You can use any of the aggregate functions available on Salesforce, namely: AVG,COUNT, COUNT(field), COUNT_DISTINCT, MIN, MAX, or SUM.
  • DataType is the type of data. You can specify: number, date, datetime, text or textarea.
  • Number Format,Date Format,DateTime Format is the way in which the data is to be formatted.

Sample Code

If you want billable and non-billable totals for the timecard hours for each resource, you can use something like this:

<output_list object="pse__Timecard_Header__c" relation="pse__Project__c">
<filters>
<filter field="pse__End_Date__c" operator="equal" value="<field name="Status_Report_Week_Ending__c" format="yyyy-mm-dd" />" />
</filters>
<tr>
<td width="185"><ol_field name="pse__Resource__r.Name"/></td>
<td width="50" align="right"><ol_field name="pse__Sunday_Hours__c" format="0.0"/></td>
<td width="50" align="right"><ol_field name="pse__Monday_Hours__c" format="0.0"/></td>
<td width="50" align="right"><ol_field name="pse__Tuesday_Hours__c" format="0.0"/></td>
<td width="50" align="right"><ol_field name="pse__Wednesday_Hours__c" format="0.0"/></td>
<td width="50" align="right"><ol_field name="pse__Thursday_Hours__c" format="0.0"/></td>
<td width="50" align="right"><ol_field name="pse__Friday_Hours__c" format="0.0"/></td>
<td width="50" align="right"><ol_field name="pse__Saturday_Hours__c" format="0.0"/></td>
<td width="50" align="right"><ol_field name="pse__Total_Hours__c" format="0.0"/></td>
</tr>
</output_list>
<aggregated_output_list object="pse__Timecard_Header__c" relation="pse__Project__c" group_by="pse__Billable__c">
<filters>
<filter field="pse__End_Date__c" operator="equal"
value="<field name="Status_Report_Week_Ending__c" format="yyyy-mm-dd" />" />
</filters>
<tr>
<td width="185">if operator="equal"><left_term><aol_field name="pse__Billable__c"/></left_term><right_term>True</right_term><true>Billable Total</true><false>Non-Billable Total</false></if></strong></td>
<td width="50" align="right"><strong><aol_field name="pse__Sunday_Hours__c" alias="sun" aggregate_function="sum" type="number" format="decimals:2;" /></strong></td>
<td width="50" align="right"><strong><aol_field name="pse__Monday_Hours__c" alias="mon" aggregate_function="sum" type="number" format="decimals:2;" /></strong></td>
<td width="50" align="right"><strong><aol_field name="pse__Tuesday_Hours__c" alias="tue" aggregate_function="sum" type="number" format="decimals:2;" /></strong></td>
<td width="50" align="right"><strong><aol_field name="pse__Wednesday_Hours__c" alias="wed" aggregate_function="sum" type="number" format="decimals:2;" /></strong></td>
<td width="50" align="right"><strong><aol_field name="pse__Thursday_Hours__c" alias="thu" aggregate_function="sum" type="number" format="decimals:2;" /></strong></td>
<td width="50" align="right"><strong><aol_field name="pse__Friday_Hours__c" alias="fri" aggregate_function="sum" type="number" format="decimals:2;" /></strong></td>
<td width="50" align="right"><strong><aol_field name="pse__Saturday_Hours__c" alias="sat" aggregate_function="sum" type="number" format="decimals:2;" /></strong></td>
<td width="50" align="right"><strong><aol_field name="pse__Total_Hours__c" alias="tot" aggregate_function="sum" type="number" format="decimals:2;" /></strong></td>
</tr>
</aggregated_output_list>
</table>

This results in a table that looks something like this:

You can filter information in the parent object by placing a <field> tag in the value attribute. For instance, this sample returns only those records where the Status_Report_Run_For__c field matches the Date__c field on the parent record:

<filter field="Date__c" operator="equal" value="<field name="Status_Report_Run_For__c" format="yyyy-mm-dd" />" />