Show Group List — Confluence Cloud Macro
The macro retrieves all Confluence groups and checks each group name against a specified filter value. If matching groups are found, it displays the results in the selected output format (Table, Ordered List, or Unordered List). If no matches are found, a "No groups match the filter" message is shown. Styles are applied for better presentation, and the macro allows for flexible output based on user preferences.
User Parameters
Filter value
Select a filter to search for groups
Output type parameter
Desc
Template
## Get the filter value and output type from the parameters
#set($filterValue = $parameters.filterValue)
#set($outputType = $parameters.outputType)
## Fetch all groups from the Confluence REST API
#set($groups = $ConfluenceManager.get("/wiki/rest/api/group"))
## Table styling class for AUI
#set($tableClass = "aui aui-table-sortable aui-table-interactive aui-table-rowhover")
## Initialize a flag to check if there are any matching groups
#set($foundGroup = false)
## Loop through each group and check if the group name contains the filter value
#foreach($group in $groups.results)
#if ($StringUtils.contains($group.name, $filterValue))
#set($foundGroup = true)
#break ## Exit the loop early if a match is found
#end
#end
## Render the output based on the specified output type
#if ($outputType == "Table")
<table class="$tableClass" style="width: fit-content; padding: 3px;">
#if ($foundGroup)
<thead>
<tr>
<th>Groups that match the filter: $filterValue</th>
</tr>
</thead>
#end
<tbody>
#if ($foundGroup)
#foreach($group in $groups.results)
#if ($StringUtils.contains($group.name, $filterValue))
<tr>
<td>$group.name</td>
</tr>
#end
#end
#else
<tr>
<td colspan="1">No groups match the filter: <strong>$filterValue</strong></td>
</tr>
#end
</tbody>
</table>
#end
#if ($outputType == "Ordered list")
#if ($foundGroup)
<p style="padding: 3px;">
Groups that match the filter: <strong>$filterValue</strong>
</p>
<ol style="width: fit-content;">
#foreach($group in $groups.results)
#if ($StringUtils.contains($group.name, $filterValue))
<li style="border-bottom: 1px solid #DFE1E6; padding: 3px;">$group.name</li>
#end
#end
</ol>
#else
No groups match the filter: <strong>$filterValue</strong>
#end
#end
#if ($outputType == "Unordered list")
#if ($foundGroup)
<p style="padding: 3px;">
Groups that match the filter: <strong>$filterValue</strong>
</p>
<ul style="width: fit-content;">
#foreach($group in $groups.results)
#if ($StringUtils.contains($group.name, $filterValue))
<li style="border-bottom: 1px solid #DFE1E6; list-style-type: circle; padding: 3px;">$group.name</li>
#end
#end
</ul>
#else
No groups match the filter: <strong>$filterValue</strong>
#end
#endRecommended Macros
Display the groups a specified Confluence user belongs to in different formats.
Display a list of Confluence pages with CSV download feature
Compare unique and common groups between two users
Display Jira issue comments in a table
Manage frequently used images (for instance, partner's logo) in one place across the whole Confluence instance without re-uploading them on each page. User parameters allow setting the image size.
Retrieve and display labels from a specified space.
Display Confluence users filtered by their email addresses.
Macro for printing all the spaces