Filter page results based on user

Scenario

This recipe shows you how to filter the page results based on the user. 

As the example in the result, we are filtering the page that has been created by 'Kevin Lew' and displaying the page information in a table. 

Result

Recipe

Apps

Scaffolding Forms & Templates, Reporting for Confluence Server & Data Center

Apps

Scaffolding Forms & Templates, Reporting for Confluence Server & 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&gt;join with " "&gt;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&gt;match "(.*?)\\u0027(.*?)\\u0027(.*?)"&gt;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&gt;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&gt;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&gt;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

  1. Add a 2 x 1 table.

  2. Set the first column as Header and write "Choose User to filter".

  3. In second column, create a List Data macro and set the following parameters:
    Field Name: myUser
    Type: auto complete
    Required: uncheck
    Allow Multiple: uncheck

  4. Within List Data macro, create User Options macro.
    Set Groups to "confluence-users".

  5. Under the table, create Report On macro and set the following parameters:

    Key: data:myUser>join with " ">text:find .*?'.*?'.*?

    Injected: checked

  6. Within Report On macro, create Report Variable macro and set the following parameters:
    Name: "X"
    Value: %match:value>match "(.*?)\\u0027(.*?)\\u0027(.*?)">group 2%

  7. Under Report On macro, create Report Table and tick Injected parameter.

  8. Within Report Table macro, create Content Reporter macro and types set it to "pages".

  9. Within Content Reporter macro, create Text Filter macro and set the following parameters:
    Key: page:creator>user:name
    Exact Value: %variable:X%

  10. Within Content Reporter macro and under Text Filter macro, create Text Sort macro and set the following parameters:
    Key: page:creator>user:name
    Order: ascending

  11. Under Content Reporter macro, create four Report Column macros.

  12. Set the first Report Column macro's Title to "Page Title" and add a Report Info macro within it.
    Set the Report Info macro's Key to "page:title".
    Tick the Link To Item.

  13. Set the second Report Column macro's Title to "Creation Date".
    Set the Report Info macro's Key to "page:creation date".

  14. Set the third Report Column macro's Title to "Modification Date".
    Set the Report Info macro's Key to "page:modification date".

  15. Set the forth Report Column macro's Title to "Page Creator".
    Set the Report Info macro's Key to "page:creator>user:full name".
    Tick Link To Item.