Get the second last entry from a Scaffolding dynamic table
Scenario
This recipe retrieves the second last row of a Table Data macro when the table is dynamic in size and uses Scaffolding Table Data and Text Data macros in the reporting process.
Result
Recipe
Apps | Reporting for Confluence Data Center, Scaffolding |
|---|---|
Level | Easy |
Estimated time | 10 minutes |
Macros | Local Reporter, Report Block, Report Body, Report Info, Report Variable |
Suppliers | Scaffold Data Supplier, Variable Supplier |
Storage format
You can copy and paste this code into the Confluence Source Editor:
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="99e89354-ca3e-4f20-9afd-d8fefe26ec2e" ac:name="table-data" ac:schema-version="1">
<ac:parameter ac:name="name">mytable</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br />
</p>
<table class="wrapped">
<colgroup> <col /> </colgroup>
<tbody>
<tr>
<th>Test</th>
</tr>
<tr>
<td>
<div class="content-wrapper">
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="de37a55c-30ff-47ad-a8d2-529b6f3d9a34" ac:name="text-data" ac:schema-version="1">
<ac:parameter ac:name="name">mytext</ac:parameter>
<ac:parameter ac:name="type">line</ac:parameter>
<ac:parameter ac:name="content">text</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
</div>
</td>
</tr>
</tbody>
</table>
<p class="auto-cursor-target">
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="31238ba3-aefe-485f-b017-a4fa64511744" ac:name="report-block" ac:schema-version="1">
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="5918df0b-de40-468d-b539-bdc458bfc967" ac:name="local-reporter" ac:schema-version="1">
<ac:parameter ac:name="">@self</ac:parameter>
<ac:rich-text-body>
<p>
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="1c0bb109-7065-4f26-9d34-87a9dfcd0cee" ac:name="report-variable" ac:schema-version="1">
<ac:parameter ac:name="name">rev</ac:parameter>
<ac:parameter ac:name="value">%data:mytable > reverse%</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="b23a771b-80c3-4d79-8f1f-1950a8ddac08" ac:name="report-body" ac:schema-version="1">
<ac:rich-text-body>
<p>Getting the second last entry from Table Data Macro: <br />
<ac:structured-macro ac:macro-id="e2932c5e-7ae4-4c0a-aa21-1e374e196889" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">variable:rev > 2 >mytext</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
Macro structure
You can recreate the example in the editor view:
Steps
Create a Table Data macro (from the Scaffolding app) with Name:
mytableto create a dynamic table that allows users to enter data.Inside the Table Data macro, create a table with one column and two rows and enter a title for the header row, for example,
Cities.In the second row, under the Cities column, create a Text Data macro (from the Scaffolding app) with the following parameters:
Field Name:
mytextType:
lineContent:
text
Outside the Table Data macro, create a Report Block macro with Injected: selected.
Within the Report Block macro, create a Local Reporter macro with Key:
@self.Under the Local Reporter macro, create a Report Variable macro with the following parameters:
Name:
revValue:
%data:mytable > reverse%
Under the Report Variable macro, create a Report Body macro with the following text within its macro body:
Getting the second last entry from Table Data macro:Under the text within the Report Body macro body, create a Report Info macro with Key:
variable:rev > 2 >mytext.