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.

up vote 0 down vote accepted

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

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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