How do I get both the names and the ids of all the groups using apex?

Or, since I know the name of the group I'm looking for, how can I get the id of a specific group based on its name?

I'm looking at this api.

Apparently ConnectApi.getGroups > group.information.title isn't the name of the group, nor does that give you the id of the group.

I could use ConnectApi.searchGroups, , but that returns the same thing as getGroups.


ConnectApi.​Chatter​Group​Detail is a subclass of ConnectApi.ChatterGroup, which is where the "name" and "id" properties are. So instead of looking at group.information.title, look at group.name and group.id. (Actually, the "id" property is in the ConnectApi.ActorWithId class, but you get the idea.)


We don't need to use ConnectAPI, this can be done using simple SOQL. Select id,name from CollaborationGroup

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.