Scenario
A report that shows the count of all direct children pages and descendant (indirect children) pages of a page.
...
Create a new page for the report and give it a suitable title. Then insert a Reporting macro.
In the Reporting window, under Query, type the Confluence Query Language (CQL) syntax that will allow you to search for the parent page, whose children and descendants you want to report on. Refer to this Atlassian article for more information on the CQL syntax.
The example CQL below:type=page AND title="Get Started"
will match all pages with the title "Get Started" in the current space. Click Search and confirm that your CQL syntax is matching the parent page.Now continue to the Add expansions section, which helps you retrieve more data from your query. Check the following boxes to retrieve all children and descendants pages of the “Get Started” page: children and then page after expanding under children, similarly descendants and then page after expanding.
We'll start by building Let’s build the first column for the report (leftmost column), which will contain the employee’s name.
In the dropdown, Choose ScaffoldingParent page. Go to the Add report blocks section to add the first block, which will be your first column too.
Make sure that Basic is selected in the dropdown, then click on Add block.
Click on "Block 0", then under Title, key in "Name", and under Field Group Name, select the correct Field Group from the listthe Block box and type Parent Page next to Block title and next to Value, select content.title to show the title of the parent page. For this example, it is "profile_group" Get Started.
Continue by clicking on Field Name. A list of fields will appear. Select the field that matches the title. For this example, it is "employee_name". Click Update to continue.
Look at the screenshot to see how the block’s settings and preview should appear:
Next, let’s add the second column for of the report, which will display employees' positionsdisplays the count of direct child pages under the Get Started (parent) page.
Again, under Add report blocks choose Scaffolding Basic in the dropdown, then click on Add block.
Click on "Block 1", then under Title, key in "Position", and under Field Group Name, select the correct Field Group from the list. For this example, it is "profile_group". Click on Field Name. A list of fields will appear. Select the field that matches the titlethe Block box and type Direct Children Count next to Block title and next to Value, select content.children.page.size to show the number of direct children of the Get Started page. For this example, it is "employee_position". Click Update to continue.
3.
Repeat step 7 5 for the two remaining columns, "Start date" and "Employee ID". Make sure you match the field to the title each time.
Under Report Type, choose Table (the default). Then, we'll add some error handling by filling out the Empty Report section. This text is shown if the report has no results. For this example, we'll enter "No matching profiles were found. Please try again later." You will also see a preview of the report here.
Save your report, Publish the page, and you're done.
Steps
The template mentioned above will generate a report on content created by you. This is specified by a section of the CQL query which is, creator=currentUser()
.
You can easily create a report on content created by another user just by changing the creator value to the user's account ID. For example, if the user account ID is 621dabxxxxx4c0070ad1fe7, then the CQL should be:
creator="621dabxxxxx4c0070ad1fe7"
...
You can obtain a user's account ID by following these steps:
In Confluence or Jira, click on the People tab, and either select or search for the user you are interested in. View their profile.
The URL of their profile page will include their user account ID at the end. It will look a like string of random letters and numbers. You can copy this string and use it for CQL queries.
Notes
Info |
---|
This recipe is now part of Reporting's built-in templates. You can easily load it into your page by using the templates feature. |
...
Note |
---|
By default, the report is limited to 200 results. Enable Get all results below the search box if you need to view more results. |
Caveats
...
last column, which displays the count descendant pages (indirect children) under the Get Started (parent) page. Type All Descendants Count for the Block title and choose content.descendants.page.size.
Note that descendant pages also include direct children pages in their count. This means that if under the Get Started Page, you have five total pages, the descendants will show that you have five pages under the Get Started page, no matter if they are direct children pages or you need to drill down 3 levels to reach them.
Check the Preview and Save your report
Publish the page, and you're done.