report-table
An HTML content command that modifies the table it is set on so that it can display the contents of a report. The resolved value of this command's primary attribute should therefore be a Report Data value.
Table structure
This content command should only be placed on a table
element and this table should have an amount of rows corresponding to the kind of report the Report Data value describes. These rows are used as models for producing the different grouping and detail rows, meaning that all the record detail rows, for example, will be exact copies of the detail row model in all but the dynamic content in their cells. If the table contains a tbody
element, only rows within that body are used as models - any rows within a thead
element are not affected by this logic attribute.
The expected amount of rows varies depending on the type of the report and the secondary attributes' resolved values:
If the report is of the Summary format, the table should have one model row for every level of grouping in the report. The first row of the table is for the highest grouping level. There may be one to three groupings, so as many possible rows.
Ifreport-table-details
is undefined or resolves intotrue
, one additional model row for the record details is needed. This row is to follow the grouping rows.
Ifreport-table-total
is undefined or resolves intotrue
, one additional row is needed for the grand totals. This row should follow the details row.If the report is of the Tabular format, the secondary attributes fully control what, if anything, appears in the table. If both of them resolve into
true
, at least two rows are needed.
Ifreport-table-details
is undefined or resolves intotrue
, all but the last row of the table are model rows for the record details. It is therefore possible to have the details of each record take multiple rows. There should be at least one row for this.
Ifreport-table-total
is undefined or resolves intotrue
, the last row of the table is used for grand totals.
If the amount of rows is not correct, an error telling the expected number will appear upon evaluation.
Displaying the report data
During the production of the all the grouping and detail rows, variables containing specific parts of the Report data corresponding to the currently processed row can be accessed. These variables are described below.
In each of the grouping rows, a variable containing a Report Data - Group Container value of that grouping level may be accessed. The name of that variable is either gr1
, gr2
or gr3
, the first being for the highest grouping level and the last for the lowest level. So, to display the label and value of the highest grouping for example, use gr1.label
and gr1.preformatted
or gr1.value
with content in that grouping's model row.
In each of the detail rows, a variable containing a Map of the column values as Report Data - Value Container values may be accessed. The name of that variable is det
and the keys are labels and Report API names of the fields. The labels are the column labels you can see in Salesforce's rendition of the reports, such as "Opportunity Name" and "Probability (%)", but do note that these are localized and therefore vary between users of different languages. Use expressions like det['AMOUNT'].value
and det['PROBABILITY'].preformatted
in the detail row model to display the detail values.
In the row for grand totals, a variable containing the Report Data - Group Container value for the grand totals may be accessed with the variable name tot
. This value only contains the label
and aggregates
data entries. For example, an expression like ${tot.label} (${tot.aggregates['RowCount']} records)
could resolve into "Grand Totals (196 records)".
This command has a priority of 90.
Secondary attributes
report-table-details | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
Defines if the detail rows of the report will be displayed. If this attribute's value resolves into If undefined, the value of |
report-table-total | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
Defines if the total row of the report will be displayed. If this attribute's value resolves into If undefined, the value of |
Examples
The report-table
content command takes a lot more setup than other HTML content commands and therefore may produce many more questions of how to use it, so this example shows a complete HTML table for displaying a report. The Report data in question - stored in the variable "report" - is of an Opportunity report of the Summary format with three grouping levels and the columns Opportunity Name, Amount and Probability, with both details and grand totals included. This makes it so that report-table
requires its host table to have 5 rows: 3 for the groupings, 1 for details and 1 for grand totals. They also need to be in a specific order, so take a look at the descriptive class names of the rows to see which is which. Also since the host table has a tbody
element, report-table
only pays attention to the rows within that element, leaving the header row of thead
untouched.
<table dyn-report-table="report"><thead><tr><th>Opportunity name</th><th>Amount</th><th>Probability</th></tr></thead><tbody><tr class="grouping-one"><td dyn-content="${gr1.label}: ${gr1.preformatted}" colspan="3">group1</td></tr><tr class="grouping-two"><td dyn-content="${gr2.label}: ${gr2.preformatted}" colspan="3">group2</td></tr><tr class="grouping-three"><td dyn-content="${gr3.label}: ${gr3.preformatted}" colspan="3">group3</td></tr><tr class="details"><td dyn-content="det['OPPORTUNITY_NAME'].preformatted">name</td><td dyn-content="det['AMOUNT'].preformatted">amount</td><td dyn-content="det['PROBABILITY'].preformatted">prob</td></tr><tr class="grand-totals"><td dyn-content="tot.label">total</td><td dyn-content="tot.aggregates['s!AMOUNT'].preformatted">sum</td><td></td></tr></tbody></table>