How can we get the Type of a Group Member?
Using getSObjectType() on the UserOrGroupId of GroupMember we get the Types – but they are only User or Group.
List<GroupMember> members = [ SELECT Id, UserOrGroupId FROM GroupMember WHERE GroupId IN (SELECT id FROM Group where Id = :groupId) ];
for(GroupMember member: members) {
System.debug(member.Id.getSObjectType() + '-' + member.UserOrGroupId.getSObjectType());
}
Any help/suggestions is appreciated.
Best Answer
Your code will look like this: