Filter page results based on user
Scenario
This recipe shows you how to filter the page results based on the user.
Result
In this example, we are filtering the pages created by Kevin Lew and displaying the page information in a table.
Recipe
Apps | Scaffolding Forms & Templates for Confluence Data Center, Reporting for Confluence Data Center |
|---|---|
Level | Intermediate |
Estimated time | 15 minutes |
Macros | Content Reporter, Report Column, Report Info, Report On, Report Variable, Text Filter, Text Sort |
Suppliers | Page Supplier, Scaffold Data Supplier, User Supplier |
Storage format
You can copy and paste this code into the Confluence Source Editor:
<table class="wrapped relative-table" style="width: 16.2221%;">
<colgroup> <col style="width: 37.7506%;"/> <col style="width: 62.1381%;"/> </colgroup>
<tbody>
<tr>
<th style="text-align: center;">Choose User to filter</th>
<td style="text-align: center;">
<div class="content-wrapper">
<ac:structured-macro ac:macro-id="87ae3a39-7372-45f9-847b-48e953d28f47" ac:name="list-data" ac:schema-version="1">
<ac:parameter ac:name="name">myUser</ac:parameter>
<ac:parameter ac:name="type">auto complete</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="b1dd79fd-5fe3-457e-aea3-4455a92fc6de" ac:name="user-options" ac:schema-version="1">
<ac:parameter ac:name="groups">confluence-users</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
</div>
</td>
</tr>
</tbody>
</table>
<ac:structured-macro ac:macro-id="46f160af-69d9-4488-8328-c605e5ed8d08" ac:name="report-on" ac:schema-version="1">
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:parameter ac:name="">data:myUser>join with " ">text:find .*?'.*?'.*?</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="c1c28d25-a7d2-4e2f-9c67-d2973a815a7e" ac:name="report-variable" ac:schema-version="1">
<ac:parameter ac:name="name">X</ac:parameter>
<ac:parameter ac:name="value">%match:value>match "(.*?)\\u0027(.*?)\\u0027(.*?)">group 2%</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>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="6041c8db-a9d6-4da5-a853-50b8bd15ad6b" ac:name="report-table" ac:schema-version="1">
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="80f6b76f-2b6d-4585-898b-7b7ab61c7825" ac:name="content-reporter" ac:schema-version="1">
<ac:parameter ac:name="types">page</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="a9728685-7235-454b-9065-77cf20cf3d03" ac:name="text-filter" ac:schema-version="1">
<ac:parameter ac:name="value">%variable:X%</ac:parameter>
<ac:parameter ac:name="">page:creator>user:name</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="bbcbcfa4-41d4-4d8f-9d16-7a744a4bbdab" ac:name="text-sort" ac:schema-version="1">
<ac:parameter ac:name="">page:creator>user:name</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="860ddd0c-39e5-4fb3-864d-2df586d22470" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Page Title</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<ac:structured-macro ac:macro-id="f54dfce0-7351-4db9-9328-b3f0b5f3231f" 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="53a45193-6d06-42d6-af60-37b776e1ebdb" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Created Date</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="9e1357a2-8ea4-4852-a137-6d2586069e53" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">page:creation date</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="40bb7e8d-fb0b-4a42-b29e-dd3536ad1279" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Last Updated</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="7b0e9213-8175-4087-860c-c23ff0e93d6a" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">page:modification date</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="a3d9d6a0-322e-40bb-8c70-380766c1738b" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="injected">true</ac:parameter>
<ac:parameter ac:name="title">Page Creator</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<ac:structured-macro ac:macro-id="55de3358-bbde-4740-81a6-2e539d27265c" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">page:creator>user:name</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p class="auto-cursor-target">
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
<p class="auto-cursor-target">
<br/>
</p>
<p>
<br/>
</p>
<p>
<br/>
</p>
Macro structure
You can recreate the example in the editor view:
Steps
Add a 2 x 1 table with a header column.
In the header column, enter
Choose User to filter.In the second column, create a Scaffolding List Data macro and set the following parameters:
Field Name:
myUserType: auto complete
Required: clear
Allow Multiple: clear
Within the List Data macro, add a User Options macro with the Group(s) set to
confluence-users.Under the table, create a Report On macro and set the following parameters:
Key:
data:myUser>join with " ">text:find .*?'.*?'.*?Injected: selected
Within the Report On macro, add a Report Variable macro and set the following parameters:
Name:
XValue:
%match:value>match "(.*?)\\u0027(.*?)\\u0027(.*?)">group 2%
Under the Report On macro, add a Report Table and select the Injected parameter.
Within the Report Table macro, add a Content Reporter macro with Types set to
pages.Within the Content Reporter macro, add a Text Filter macro and set the following parameters:
Key:
page:creator>user:nameExact Value:
%variable:X%
Within the Content Reporter macro, under the Text Filter macro, create a Text Sort macro and set the following parameters:
Key:
page:creator>user:nameOrder: ascending
Under the Content Reporter macro, create four Report Column macros with Title parameters set to
Page Title,Creation Date,Modification Date, andPage Creator.Within the Page Title Report Column, add a Report Info macro within Key set to
page:titleand select Link To Item.Within the Creation Date Report Column, add a Report Info macro within Key set to
page:creation date.Within the Modification Date Report Column, add a Report Info macro within Key set to
page:modification date.Within the Page Creator Date Report Column, add a Report Info macro within Key set to
page:creator>user:full nameand select Link To Item.