Scenario

The Add page macro (part of the Linking app) can automatically generate pages with incremental numbers in the titles, for example, Incident Report 001, Incident Report 002, Incident Report 003, and so on.

Result

This example recipe will generate such pages.

You may also need to inject the incrementing numbers into each generated page. For example, you might have a "Report Number" field and it must contain the same three-digit number from the title:

Report Number: 001
Report Number: 002
Report Number: 003 and so on

This recipe will automatically create pages with incrementing numbers, along with matching number fields in the pages.

Recipe

Apps

Reporting for Confluence Server & Data Center, Linking for Confluence Server

Level

Intermediate

Estimated time

25 minutes

Macros

Report Info, Report Variable

Suppliers

Child Counter Supplier

Storage format

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


<p>
  <ac:structured-macro ac:macro-id="1ecd3808-f211-433c-8993-552ccfd14884" ac:name="add-page" ac:schema-version="1">
    <ac:parameter ac:name="name">Incident Report %child-counter:next &gt; number:000%</ac:parameter>
    <ac:parameter ac:name="linkText">Create a new incident report</ac:parameter>
    <ac:parameter ac:name="source">Incident Report Template</ac:parameter>
  </ac:structured-macro>
</p>
<p>
  <ac:structured-macro ac:macro-id="46068b0f-91dd-4927-aa7d-38e2b74e50ee" ac:name="children" ac:schema-version="2">
    <ac:parameter ac:name="sort">title</ac:parameter>
  </ac:structured-macro>
</p>
CODE

Macro structure

You can recreate the example in the editor view:

  • N/A

Steps

  1. Create a landing page by using the storage format code above, and provide a suitable name, such as "Incident Report Main Page".

  2. For this recipe to work properly, you will also need to create a template file for incident reports. This file is loaded whenever users click on "Generate an incident report". You can copy and paste the code below for your template file with the Confluence Source Editor:

    <ac:structured-macro ac:macro-id="c0f2b51e-ad37-4dd1-81c0-7783cebc11da" ac:name="report-variable" ac:schema-version="1">
      <ac:parameter ac:name="default">%page:title> text:last 3%</ac:parameter>
      <ac:parameter ac:name="name">pageNum</ac:parameter>
      <ac:parameter ac:name="value">%page:title> text:last 3%</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>
    <p>
      <br/>
    </p>
    <p>
      <br/>
    </p>
    <table class="wrapped relative-table" style="width: 56.3614%;">
      <colgroup> <col style="width: 55.4387%;"/> <col style="width: 44.6494%;"/> </colgroup>
      <tbody>
        <tr>
          <td>
            <div class="content-wrapper">
              <p>
                <strong>Report Number:</strong> <ac:structured-macro ac:macro-id="2d8755ec-9cb7-4cd3-8d2b-7cf098b26bdc" ac:name="report-info" ac:schema-version="1">
                  <ac:parameter ac:name="">variable:pageNum</ac:parameter>
                </ac:structured-macro>
              </p>
            </div>
          </td>
          <td>
            <div class="content-wrapper">
              <p>
                <strong>Date: </strong>
              </p>
              <ac:structured-macro ac:macro-id="9d970e6e-8320-48b8-9175-ff6d6da7b6ed" ac:name="date-data" ac:schema-version="1">
                <ac:parameter ac:name="name">datepicker</ac:parameter>
                <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
              </ac:structured-macro>
            </div>
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <div class="content-wrapper">
              <p>
                <strong>Incident Details:</strong>
              </p>
              <ac:structured-macro ac:macro-id="d39b9896-1c77-4f8d-b297-ee10f68925db" ac:name="text-data" ac:schema-version="1">
                <ac:parameter ac:name="name">details</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>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
    
    CODE
  3. Save the file and provide a suitable name, such as "Incident Report Template". You can either save it as a template (requires space admin privileges) or as just a standard Confluence page.

  4. After you have created and saved the template, you can reference it from the Add Page macro used for the landing page. Edit the landing page, and edit the Add Page macro within.

  5. In the Edit 'Add Page' Macro window, type or paste the template page name under Source, and select either template or page under Source Type, depending on what you used in the earlier step.

  6. Click Save, then click Save again to save the landing page. 

  7. The landing page is now available to users.