Expand my Community achievements bar.

SOLVED

How to get the list of user's group which is having count of user's less than 5?

Avatar

Level 5

Hi all,

 

How to get the list of user's group which is having count less than 5 using query debugger? Please share the query statement for this condition. Aem version is aem cloud

 

Thank you.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

No, you can't check that.

I don't know your use case but you can leverage jcr:createdBy property to filter out further



Arun Patidar

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @keerthana_hn 

I dont think you can a write a query in debugger to find the number of users in each group. You might need to use the group API [1] in custom code and call the getMembers() method and iterate it to find the size.

 

[1] https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/org/apache/jackrabbit...

Avatar

Community Advisor

Hi,

You cannot achieve this using query alone, once you have results from below query then you need to write java code to check group member count

 

type=rep:Group
path=/home/groups
property=rep:members
property.value=true
property.operation=exists
p.limit=-1

 

arunpatidar_0-1668521394228.png

 

UserManager userManager = resourceResolver.adaptTo(UserManager.class);
Group group = (Group)  userManager.getAuthorizable(groupFromQuery);
if (group.getMembers() < 5){
// TODO
}

 



Arun Patidar

Avatar

Level 5

Hi @arunpatidar ,

Can we check in query debugger whether the group is automatically created? Or is there any property that defines automatically created group?

Avatar

Correct answer by
Community Advisor

No, you can't check that.

I don't know your use case but you can leverage jcr:createdBy property to filter out further



Arun Patidar