function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Getting all groups and it's members via soql query

How do I go about getting all groups and it's members via a soql query?


SELECT Id, DeveloperName, GroupMember
FROM Group


I tried this and it gave me an error.


GroupMember is a child to Group. Try:


(SELECT Id, UserOrGroupId FROM GroupMembers)
FROM Group


Vaughan Coder 32Vaughan Coder 32

Minor nitpick on lrw's answer - It should be "GroupMember" not GroupMembers

GroupMembers is correct because it is a subquery.  If you were querying the GroupMember object directly then it would be the singular form.