Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,467
Community Members
 
Community Events
165
Community Groups

Get Space Admins for all Confluence Spaces Using Macro

Hi community,

I'm new to macros on Confluence so forgive me!

I found this macro from the community site and I want to pull out only individuals who are named as space admins. I don't want to pull the groups out.

How would this be done?

Right now, it pulls out the space name, key and all the admins on the spaces. I'm just looking to either exclude the groups or just pick named individuals.

Here is the code:

## @noparams
#set($D = "$")
#set($P = "#")

#set($users = $userAccessor.getUsers())
#set($spaces = $spaceManager.getAllSpaces())

<div id="conf-space-lister"><ul><span id="conf-space-loading" class="aui-icon aui-icon-wait">Loading...</span></ul></div>
<div id="conf-spacetbl-lister">
<table class="confluenceTable tablesorter tablesorter-default stickyTableHeaders" role="grid" resolved="" style="padding: 0px;"><colgroup><col><col><col></colgroup>
</table>
</div>

<pre><script>
AJS.${D}('${P}conf-space-loading').remove()
AJS.${D}('${P}conf-spacetbl-lister table').append('<tr><td colspan="3"><p><b>Found ' + $spaces.size() + ' Spaces</b><br><br></p></td></tr>');

AJS.${D}('${P}conf-spacetbl-lister table').append('<tr role="row" class="tablesorter-headerRow"></th><th class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="0" tabindex="1" scope="col" role="columnheader" aria-disabled="false" unselectable="on" aria-sort="none" aria-label="Name: No sort applied, activate to apply an ascending sort" style="user-select: none; min-width: 8px; max-width: none;"><div class="tablesorter-header-inner">Space Name</div></th><th class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="1" tabindex="2" scope="col" role="columnheader" aria-disabled="false" unselectable="on" aria-sort="none" aria-label="Value: No sort applied, activate to apply an ascending sort" style="user-select: none; min-width: 8px; max-width: none;"><div class="tablesorter-header-inner">Space Key</div></th><th class="confluenceTh tablesorter-header sortableHeader tablesorter-headerUnSorted" data-column="2" tabindex="3" scope="col" role="columnheader" aria-disabled="false" unselectable="on" aria-sort="none" aria-label="Value: No sort applied, activate to apply an ascending sort" style="user-select: none; min-width: 8px; max-width: none;"><div class="tablesorter-header-inner">Space Administrators</div></th></tr>');


#foreach($spacer in $spaces)
AJS.${D}('${P}conf-spacetbl-lister table').append('<tr><td class="confluenceTd"><a href="$spacer.getUrlPath()">$spacer.name</a></td><td class="confluenceTd">$spacer.key</td><td class="confluenceTd">#set($admins=$spaceManager.getSpaceAdmins($spacer)) #foreach($admin in $admins) $admin.name, #end</td></tr>');
#end

AJS.${D}('${P}conf-spacetbl-lister table').append('</tbody></table>');
</script></pre>

 Thanks in advance

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: AppLiger

This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity.    Atlassian:...

330 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you