Extracting Scaffolding Data from children pages and modifying values using Reporting macro
Scenario
This recipe is relevant for page structures containing a parent page and children pages like below:

In the child pages, a simple form is created by adding Scaffolding macros directly inside a HTML table (no Scaffolding's Table Data macro is used).

This recipe shows how to extract text fields from the Text Data macro, modify the value and display it in a report on a different page.
In this example we are capturing a field named "Website" in the children pages (eg. www.google.com/about).
The macro will modify the website value so that only the main website URL (eg. www.google.com) is displayed in the Reporting (Parent) page.
Result
Recipe
Ingredients
Apps | |
---|
Platform | Server, Data Center |
---|
Level | |
---|
Estimated time | |
---|
Macros | |
---|
Suppliers | |
---|
Storage format
You can copy and paste this code into the Confluence Source Editor:
<h3>List of Projects (children pages)</h3>
<ac:structured-macro ac:macro-id="27c5f2f3-687b-46e0-84f7-d33340f5e35b" ac:name="report-table" ac:schema-version="1">
<ac:parameter ac:name="maxResults">50</ac:parameter>
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="3873234a-c279-4276-81d5-e8d1a4112ba4" ac:name="local-reporter" ac:schema-version="1">
<ac:parameter ac:name="">page:children</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="62120575-4f33-467a-bb82-6d9706452586" ac:name="text-sort" ac:schema-version="1">
<ac:parameter ac:name="">page:title</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="b96a5da3-d43c-4510-969e-9b745d124f59" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Page Title</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="eff96fa7-4f11-4bf3-bd3e-9e0ced4e7ccd" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">page:title</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="7d868e37-98d2-4d58-ad8e-828d144e9d19" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Project Name</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="e4a221f0-e12d-486a-a169-8565acf4153a" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">data:proj_name</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="900105cf-8207-4d74-873b-112aa45bc1ad" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Location</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="f94b8215-bf8c-4915-a4e8-008bf9156d61" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">data:proj_location</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="f3b891b9-1948-4ffe-bda9-c46b95c1bf7f" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Priority</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="4d312c32-2b84-459d-b0a8-26d5b59da85f" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">data:proj_priority</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="bc1f0654-e26a-4d74-98f3-87c339bf36fc" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:parameter ac:name="title">Website</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="e8988ae3-167f-42ae-ab5d-7c3aae242c4f" ac:name="report-block" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="0e0a56b6-ab34-4f32-b564-a6c349937956" ac:name="local-reporter" ac:schema-version="1">
<ac:parameter ac:name="">@self</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="f4b830ff-a13e-4323-8c82-5ccbd9b62cbd" ac:name="text-filter" ac:schema-version="1">
<ac:parameter ac:name="include">.*//.*</ac:parameter>
<ac:parameter ac:name="">data:proj_website</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="2653d136-b433-4262-bfea-df359f19643c" ac:name="report-body" ac:schema-version="1">
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="e3cb4379-50ce-42da-8873-3eefcf9f51e8" ac:name="report-link" ac:schema-version="1">
<ac:parameter ac:name="trim">true</ac:parameter>
<ac:parameter ac:name="title">%page:title% - Website</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:parameter ac:name="target">_blank</ac:parameter>
<ac:parameter ac:name="">data:proj_website</ac:parameter>
<ac:rich-text-body>
<p>%data:proj_website > text:split with // > collection:last > text:split with / > collection:first%</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="06cdb4f3-e741-47ad-a242-38ffdf32d331" ac:name="report-empty" ac:schema-version="1">
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="e3869985-21f8-4182-bfba-1d546e6502ab" ac:name="report-link" ac:schema-version="1">
<ac:parameter ac:name="trim">true</ac:parameter>
<ac:parameter ac:name="title">%page:title% - Website</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:parameter ac:name="target">_blank</ac:parameter>
<ac:parameter ac:name="">data:proj_website</ac:parameter>
<ac:rich-text-body>
<p>%data:proj_website > text:split with / > collection:first%</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="d5ea2816-c158-40b4-8592-313fc943708e" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Phone</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="d4fff7b2-ea51-4269-92c4-55fba14734c1" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">data:proj_phone</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="27dfb4f5-c421-4881-b8d9-7d7c374ac32b" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Email</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="c2fb1b6f-88c6-4b3e-ba1f-acd536b838cc" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">data:proj_email</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="56078793-c79b-43ba-b0ca-ce13b7637aa0" ac:name="report-empty" ac:schema-version="1">
<ac:rich-text-body>
<p>No results found!</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
Macro structure
You can recreate the example in the editor view:
Steps
- Add a Report Table macro and within add a Local Reporter macro. Set the Local Reporter macro's Key parameter to
page:children
.
- Inside the Local Reporter macro, add a Text Sort macro and set the Key to
page:title
.
- Below the Local Reporter macro, add a Report Column macro and set the macro's Title to "Page Title".
- Add a Report Info macro within the Report Column macro and set the macro's Key to
page:title
and Link to item to True. - Add another Report Column macro and set the macro's Title to "Project Name".
- Add a Report Info macro within the Report Column macro and set the macro's Key to
data:proj_name
. - Add another Report Column macro and set the macro's Title to "Location".
- Add a Report Info macro within the Report Column macro and set the macro's Key to
data:proj_location
.
- Add another Report Column macro and set the macro's Title to "Priority".
- Add a Report Info macro within the Report Column macro and set the macro's Key to
data:proj_priority
. - Add another Report Column macro and set the macro's Title to "Website" and set Injected to True.
- Inside the Report Column macro, add a Report Block macro.
- Inside the Report Block macro, add a Local Reporter macro. Set the Local Reporter macro's Key parameter to
@self.
- Inside the Local Reporter macro, add a Text Filter macro and specify the following:
- Key:
data:proj_website
- Include:
.*//.*
(This will look for every website value that contains //
in their URL)
- Below the Local Reporter macro, add a Report Body macro.
- Inside the Report Body macro, add a Report Link macro and specify the following:
- Key:
data:proj_website
- Trim URL Whitespace:
True
- Title:
%page:title% - Website
- Target Frame:
_blank
- Right inside the Report Link macro, enter the following value:
%data:proj_website > text:split with // > collection:last > text:split with / > collection:first%
- Below the Report Body macro, add a Report Empty macro.
- Inside the Report Empty macro, add a Report Link macro and specify the following:
- Key:
data:proj_website
- Trim URL Whitespace:
True
- Title:
%page:title% - Website
- Target Frame:
_blank
- Right inside the Report Link macro, enter the following value:
%data:proj_website > text:split with / > collection:first%