Extract Scaffolding data from child pages and modify values using Reporting
Scenario
This recipe is relevant for page structures containing a parent page and child pages like the below:
In the child pages, a simple form is created by adding Scaffolding macros directly inside an HTML table (no Scaffolding 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 child pages (for example, http://www.google.com/about).
The macro will modify the website value so that only the main website URL (eg. http://www.google.com ) is displayed on the Reporting (parent) page.
Result
Recipe
Apps | Reporting for Confluence Data Center, Scaffolding Forms & Templates for Confluence Data Center |
|---|---|
Level | Intermediate |
Estimated time | 20 minutes |
Macros | Local Reporter, Report Block, Report Body, Report Column, Report Empty, Report Info, Report Link, Report Table, Text Filter, Text Sort |
Suppliers | Page Supplier, Scaffold Data Supplier |
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 it add a Local Reporter macro with the Key parameter set to
page:children.Inside the Local Reporter macro, add a Text Sort macro and set the Key to
page:title.Under the Local Reporter macro, add a Report Column macro and set the Title to
Page Title.Within the Report Column macro, add a Report Info macro, set the Key to
page:title, and select the Link to item checkbox.Add another Report Column macro and set the Title to
Project Name.Within the Report Column macro, add a Report Info macro and set the Key to
data:proj_name.Add another Report Column macro and set the Title to
Location.Within the Report Column macro, add a Report Info macro and set the Key to
data:proj_location.Add another Report Column macro and set the Title to
Priority.Within the Report Column macro, add a Report Info macro and set the Key to
data:proj_priority.Add another Report Column macro, set the Title to
Website, and select Injected checkbox.Within the Report Column macro, add a Report Block macro.
Within the Report Block macro, add a Local Reporter macro and set the Key parameter to
@self.Within the Local Reporter macro, add a Text Filter macro and specify the following:
Key:
data:proj_websiteInclude:
.*//.*. This will look for every website value that contains//in their URL.
Under 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_websiteTrim URL Whitespace:
TrueTitle:
%page:title% - WebsiteTarget Frame:
_blank
Inside the Report Link macro, enter the following value:
%data:proj_website > text:split with // > collection:last > text:split with / > collection:first%Under 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_websiteTrim URL Whitespace:
TrueTitle:
%page:title% - WebsiteTarget Frame:
_blank
Inside the Report Link macro, enter the following value:
%data:proj_website > text:split with / > collection:first%
On the Website column, create the following conditions:
Condition 1
If the URL starts with
https, then remove all the characters before//Then, search for the character
/Once the supplier finds the character
/, remove all the characters after that.
For example, the URL https://google.com/about will become http://google.com
Condition 2
If the URL does not have
https, then look for the character/which then removes all the characters after that.
For example, the URL http://www.google.com/about will become http://www.google.com