Skip to main content
Skip table of contents

Add a dropdown filter to the Space Inline Comment Report

Scenario

This recipe allows you to create an inline comment report for a specific Confluence space. 

To make this report dynamic and allow users to select which space to report on, we are using Scaffolding Forms & Templates for Confluence Server and Data Center's List Data macro. The Adding a dropdown list of users macro will appear as a dropdown menu with all available spaces for users to select from. Once the user has selected the space, the inline comment report for that particular space will be executed.

Without the Scaffolding List Data macro used in this example, users will need to edit the page and change the Spaces value in Content Reporter macro to select which Space to report on.

Result

Recipe

Apps

Reporting for Confluence Server & Data Center, Scaffolding

Level

Intermediate

Estimated time

30 minutes

Macros

Content Reporter, Report Block, Report On, Report Table, Report Variable, Space Reporter, Text Filter

Suppliers

Comment Supplier

Storage format

You can copy and paste this code into the Confluence Source Editor:

CODE
<ac:layout>
  <ac:layout-section ac:type="single">
    <ac:layout-cell>
      <table class="wrapped">
        <colgroup>
          <col />
          <col />
        </colgroup>
        <tbody>
          <tr>
            <td>Please select the Space you wish to report on:</td>
            <th>
              <div class="content-wrapper">
                <ac:structured-macro ac:macro-id="8aa7e2e6-8f3d-4098-b375-6d91c143c339" ac:name="list-data" ac:schema-version="1">
                  <ac:parameter ac:name="name">spaces</ac:parameter>
                  <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
                  <ac:rich-text-body>
                    <ac:structured-macro ac:macro-id="56680a6a-b074-4c13-8a56-66ebbd93a4e6" 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>
                        <ac:structured-macro ac:macro-id="6f1f33d7-7888-4d5d-8ce2-f70f65bf0ce0" ac:name="space-reporter" ac:schema-version="1">
                          <ac:rich-text-body>
                          </ac:rich-text-body>
                        </ac:structured-macro>
                        <ac:structured-macro ac:macro-id="cefedb5e-86e2-4b5e-85f5-b0b895139e27" ac:name="report-body" ac:schema-version="1">
                          <ac:rich-text-body>
                            <ac:structured-macro ac:macro-id="5c212908-639d-4e0f-9709-52fc58cc9285" ac:name="list-option" ac:schema-version="1">
                              <ac:parameter ac:name="label">%space:name%</ac:parameter>
                              <ac:parameter ac:name="value">%space:key%</ac:parameter>
                              <ac:rich-text-body>
                              </ac:rich-text-body>
                            </ac:structured-macro>
                          </ac:rich-text-body>
                        </ac:structured-macro>
                      </ac:rich-text-body>
                    </ac:structured-macro>
                  </ac:rich-text-body>
                </ac:structured-macro>
              </div>
            </th>
          </tr>
        </tbody>
      </table>
    </ac:layout-cell>
  </ac:layout-section>
  <ac:layout-section ac:type="single">
    <ac:layout-cell>
      <ac:structured-macro ac:macro-id="f8e413f3-26c8-47ac-b5d5-579e979d43b4" 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="7356aed7-4a90-459e-9805-a8b2837a5222" ac:name="content-reporter" ac:schema-version="1">
            <ac:parameter ac:name="types">comment</ac:parameter>
            <ac:parameter ac:name="spaces">
              <ri:space ri:space-key="%data:spaces>first%" />
            </ac:parameter>
            <ac:rich-text-body>
              <p>
                <ac:structured-macro ac:macro-id="1ea4eeca-aeeb-4688-9692-ea7e7b127754" ac:name="text-sort" ac:schema-version="1">
                  <ac:parameter ac:name="">comment:creation date</ac:parameter>
                </ac:structured-macro>
              </p>
              <p>
                <ac:structured-macro ac:macro-id="c7c614dd-138e-4b14-ab84-8e98d54d2033" ac:name="text-filter" ac:schema-version="1">
                  <ac:parameter ac:name="exclude">Resolved</ac:parameter>
                  <ac:parameter ac:name="required">true</ac:parameter>
                  <ac:parameter ac:name="">comment:inline-status</ac:parameter>
                </ac:structured-macro>
              </p>
            </ac:rich-text-body>
          </ac:structured-macro>
          <ac:structured-macro ac:macro-id="2f760e10-32d4-406d-a00e-b003c5f7f0e7" ac:name="report-column" ac:schema-version="1">
            <ac:parameter ac:name="title">Space</ac:parameter>
            <ac:rich-text-body>
              <p>
                <ac:structured-macro ac:macro-id="1221e78a-4dd1-4877-a103-a7e48f564763" ac:name="report-info" ac:schema-version="1">
                  <ac:parameter ac:name="">comment:space</ac:parameter>
                </ac:structured-macro>
              </p>
            </ac:rich-text-body>
          </ac:structured-macro>
          <ac:structured-macro ac:macro-id="a706f2fa-45eb-4e98-b5f5-85b4840dcf37" ac:name="report-column" ac:schema-version="1">
            <ac:parameter ac:name="title">Page</ac:parameter>
            <ac:rich-text-body>
              <p>
                <ac:structured-macro ac:macro-id="b6167193-29e7-426d-8bc4-0709916e9640" ac:name="report-info" ac:schema-version="1">
                  <ac:parameter ac:name="link">true</ac:parameter>
                  <ac:parameter ac:name="">comment:page</ac:parameter>
                </ac:structured-macro>
              </p>
            </ac:rich-text-body>
          </ac:structured-macro>
          <ac:structured-macro ac:macro-id="c0d0df5a-732f-42bd-b83a-bf427511dc17" ac:name="report-column" ac:schema-version="1">
            <ac:parameter ac:name="title">Comment</ac:parameter>
            <ac:rich-text-body>
              <p>
                <ac:structured-macro ac:macro-id="5bec0898-7e9a-43c0-b146-4a3efc81f0a6" ac:name="report-info" ac:schema-version="1">
                  <ac:parameter ac:name="link">true</ac:parameter>
                  <ac:parameter ac:name="render">richtext</ac:parameter>
                  <ac:parameter ac:name="">comment:body</ac:parameter>
                </ac:structured-macro>
              </p>
            </ac:rich-text-body>
          </ac:structured-macro>
          <ac:structured-macro ac:macro-id="0589b942-6cc0-4b5b-8118-429459297cd7" ac:name="report-column" ac:schema-version="1">
            <ac:parameter ac:name="title">Author</ac:parameter>
            <ac:rich-text-body>
              <p>
                <ac:structured-macro ac:macro-id="dcf3eb45-d53c-479a-b8b2-045389ab6078" ac:name="report-info" ac:schema-version="1">
                  <ac:parameter ac:name="">comment:creator</ac:parameter>
                </ac:structured-macro>
              </p>
            </ac:rich-text-body>
          </ac:structured-macro>
          <ac:structured-macro ac:macro-id="391fac60-a473-461f-a3d5-0d7cd7f97261" ac:name="report-column" ac:schema-version="1">
            <ac:parameter ac:name="title">Repliers</ac:parameter>
            <ac:rich-text-body>
              <p>
                <ac:structured-macro ac:macro-id="ed3e6c5a-5ea0-42de-a865-f51defeea9d9" ac:name="report-info" ac:schema-version="1">
                  <ac:parameter ac:name="">comment:repliers &gt; collection:join with ", "</ac:parameter>
                </ac:structured-macro>
              </p>
            </ac:rich-text-body>
          </ac:structured-macro>
          <ac:structured-macro ac:macro-id="6a37b846-f71d-4419-ab18-3927e07e1d28" ac:name="report-column" ac:schema-version="1">
            <ac:parameter ac:name="title">Status</ac:parameter>
            <ac:rich-text-body>
              <p>
                <ac:structured-macro ac:macro-id="ac7d2c62-6aee-4242-ad38-e0f2fb89c38a" ac:name="report-info" ac:schema-version="1">
                  <ac:parameter ac:name="">comment:inline-status</ac:parameter>
                </ac:structured-macro>
              </p>
            </ac:rich-text-body>
          </ac:structured-macro>
          <ac:structured-macro ac:macro-id="54762b7e-3c64-4f5c-b15f-928e44d7a266" ac:name="report-column" ac:schema-version="1">
            <ac:parameter ac:name="title">ReplyCount</ac:parameter>
            <ac:rich-text-body>
              <p>
                <ac:structured-macro ac:macro-id="8c46af56-32b3-43a4-8076-2e3a9f2eb148" ac:name="report-info" ac:schema-version="1">
                  <ac:parameter ac:name="">comment:reply count</ac:parameter>
                </ac:structured-macro>
              </p>
            </ac:rich-text-body>
          </ac:structured-macro>
          <ac:structured-macro ac:macro-id="8377ba93-0a47-48e1-bedb-8d0b7964c3a5" ac:name="report-column" ac:schema-version="1">
            <ac:parameter ac:name="injected">true</ac:parameter>
            <ac:parameter ac:name="title">Age</ac:parameter>
            <ac:rich-text-body>
              <ac:structured-macro ac:macro-id="2ec6bc9c-c733-4f4f-99ed-47fd5167645c" ac:name="report-eval" ac:schema-version="1">
                <ac:parameter ac:name="format">#</ac:parameter>
                <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
                <ac:plain-text-body><![CDATA[(%global:current date>date:milliseconds% - %comment:creation date>date:milliseconds%)/1000/60/60/24]]></ac:plain-text-body>
              </ac:structured-macro>
            </ac:rich-text-body>
          </ac:structured-macro>
        </ac:rich-text-body>
      </ac:structured-macro>
    </ac:layout-cell>
  </ac:layout-section>
</ac:layout>

Macro structure

You can recreate the example in the editor view:

Steps

  1. Create a List Data macro for the user to select the Space they want to report on.
    To achieve this follow the steps below:

    1. Create a Report Block macro. Set Injected parameter to True.

    2. Within the Report Block macro, create a Space Reporter macro to report on all the Spaces in Confluence.

    3. Create a Report Body macro.

    4. Within the Report Body macro, create a List Option macro to feed the spaces into a dropdown menu.
      Set the parameters as below:
      Value: %space:key%
      Label: %space:name%

  2. Create a Report Table macro.
    Set Injected parameter to True.

  3. Within Report Table macro, create a Content Reporter macro and set the following parameters:
    Type: comment
    Spaces %data:spaces>first%

  4. Within Content Reporter macro, create a Text Sort macro.
    Set the Text Sort macro's Key to "comment:creation date".

  5. Within Content Reporter macro, create a Text Filter macro.
    Set the Text Filter macro's Key to "comment:inline-status".
    Set Required parameter to True.

  6. Within Report Table macro, under Content Reporter macro, create 8 Report Column macros.

  7. Set the first Report Column macro's Title to "Space" and add a Report Info macro within it.
    Set the Report Info macro's Key to "comment:space".

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

  9. Set the third Report Column macro's Title to "Comment" and add a Report Info macro within it.
    Set the Report Info macro's Key to "comment:body".
    Tick Link To Item.

  10. Set the forth Report Column macro's Title to "Author" and add a Report Info macro within it.
    Set the Report Info macro's Key to "comment:creator".

  11. Set the fifth Report Column macro's Title to "Repliers" and add a Report Info macro within it.
    Set the Report Info macro's Key to "comment:repliers > collection:join with ", "".

  12. Set the sixth Report Column macro's Title to "Status" and add a Report Info macro within it.
    Set the Report Info macro's Key to "comment:inline-status".

  13. Set the seventh Report Column macro's Title to "Reply Count" and add a Report Info macro within it.
    Set the Report Info macro's Key to "comment:reply count".

  14. Set the eighth Report Column macro's Title to "Age" and check Injected parameter to set it to True. Then add a Report Eval macro within it. 
    Copy the following code inside the Report Eval macro:
    "(%global:current date>date:milliseconds% - %comment:creation date>date:milliseconds%)/1000/60/60/24".

  15. Save the changes.

  16. Now, you can click on Edit Contents to select the Space to report on.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.