Is there a declarative way to get all of the groups a user leads or manages?

Craig Jacobs
Giga Contributor

Hello Community. I need to find all of the groups that a user manages or leads, including groups of which the user is not a member.  I guess it's common for a user to manage a group, but not be a member of the group. An imperative implementation could just iterate over all groups and test if the user is manager or leader, but that seems really inefficient. I'm looking for something declarative like gs.getUser().getMyGroups()  which includes groups the user leads or manages but for which the user is not a member. If I have to go imperative, what's the best way to narrow down the number of records I need to check? 

Thank you in advance, this community has always been super helpful.

5 REPLIES 5

Nice clean code. Thank you Hitoshi!