You need to sign in to do that
Don't have an account?
Querying for Group members of a public group
Can someone please point out why I am not getting anything in the map if i search by Group Name ?
// Get Id of the Group named Finance_Team
Map<Id, Group> groupMap = new Map<Id, Group>([
Select Id, Name
From Group
Where Name = 'Finance_Team'
]);
// The above query doesn't return me the id of the group
//Find all members of the group
List<GroupMember> groupMembers = [
Select GroupId, UserOrGroupId
From GroupMember
Where GroupId In :groupMap.keySet()
];
put the id's of the group members in a set
Set<Id> userOrGroupIds = new Set<Id>();
for (GroupMember member : groupMembers) {
userOrGroupIds.add(member.UserOrGroupId);
}
I think "Finance_Team" is the API name of your group ? In that case you need to query on the basis of the DeveloperName field like :
Map<Id, Group> groupMap = new Map<Id, Group>([
Select Id, Name
From Group
Where DeveloperName = 'Finance_Team'
]);
All Answers
I think "Finance_Team" is the API name of your group ? In that case you need to query on the basis of the DeveloperName field like :
Map<Id, Group> groupMap = new Map<Id, Group>([
Select Id, Name
From Group
Where DeveloperName = 'Finance_Team'
]);
Thanks!!! Much appreciated
Interesting though, Force.com explorer doesn't identify the field DeveloperName, whereas IDE does.