Scenario

The Attachments macro only extracts attachment information from the current page. To retrieve information on attachments on other pages, use the recipe below.

In the example, the macro retrieved the first 6 attachments in a page called "Aircraft Parts" in the space "PLANE" and formatted the results in a table sorted by attachment name.

Result

 

Recipe

Apps

Reporting for Confluence Server

Level

Easy

Estimated time

15 minutes

Macros

Local Reporter, Report Column, Report Empty, Report Info, Report Table, Text Sort

Suppliers

Attachment Supplier, Content Supplier

Storage format

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

<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="c22dc8ab-e104-4625-b628-00f0200f85c9" ac:name="report-table" ac:schema-version="1">
<ac:parameter ac:name="maxResults">6</ac:parameter>
ac:rich-text-body
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="47be588f-0881-46fa-9571-6b699565b283" ac:name="local-reporter" ac:schema-version="1">
<ac:parameter ac:name="source">PLANE:Aircraft Parts</ac:parameter>
<ac:parameter ac:name="">content:attachments</ac:parameter>
ac:rich-text-body
<ac:structured-macro ac:macro-id="6a759018-c4f2-46c5-bc95-305e565524e5" ac:name="text-sort" ac:schema-version="1">
<ac:parameter ac:name="">attachment:title</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="a3a28fb3-5ff6-4a47-99a0-bb2b40550081" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">File Name</ac:parameter>
ac:rich-text-body
<p>
<ac:structured-macro ac:macro-id="b594ff2a-7ece-40b2-9a88-55c0ad75c288" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="link">true</ac:parameter>
<ac:parameter ac:name="">attachment:title</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="bbee1bb1-1d0c-45a6-8eef-fb2680e0fb2d" 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="53d5ef1e-e5d2-43ca-9eb2-67771b058cb9" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">attachment:comment</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="2c7a104a-9a2e-4a5b-ac0b-b726358882bd" ac:name="report-column" ac:schema-version="1">
<ac:parameter ac:name="title">Size</ac:parameter>
ac:rich-text-body
<p>
<ac:structured-macro ac:macro-id="7dfb975d-ad59-46fa-9975-98c4b6a091bf" ac:name="report-info" ac:schema-version="1">
<ac:parameter ac:name="">attachment:nice file size</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
<ac:structured-macro ac:macro-id="1b955b0f-59f3-49a8-9d2a-a9e17f374908" ac:name="report-empty" ac:schema-version="1">
ac:rich-text-body
<p>No files have been attached to this page.</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br />
</p>
CODE

 

Macro structure

You can recreate the example in the editor view:

Steps

  1. Create a Report Table macro.
    Set Maximum Results to "6".

  2. Within the Report Table, create a Local Reporter macro.
    Specify the following parameters:

    • Key: content:attachments

    • Source: PLANE:Aircraft Parts

  3. Within the Local Reporter, create a Text Sort macro.
    Set the Key to attachment:title.

  4. Within the Report Table, and beneath the Local Reporter, create a Report Column.
    Set the Title to "File Name".

  5. Within the Report Column, create a Report Info macro.
    Specify the following parameters:

    • Key: attachment:title

    • Link to Item: true

  6. Within the Report Table, create another Report Column.
    Set the Title to "Comment".

  7. Within the Report Column, create a Report Info macro.
    Set the Key to attachment:comment.

  8. Within the Report Table, create another Report Column.
    Set the Title to "Size".

  9. Within the Report Column, create a Report Info macro.
    Set the Key to attachment:nice file size.

  10. Within the Report Table, create a Report Empty macro.