Id currentUserId = UserInfor.getUserId();
List<GroupMember> lstGroupMember = [SELECT GroupId,UserOrGroupId FROM GroupMember where userorgroupid =:currentUserId];
Query in second line will give you list of GroupMember, from this list you can get IDs of all Group and query Group object to get detail of group.
Set<Id> setGroupMemberId = new Set<Id>();
List<CollaborationGroup> lstGroup = new List<CollaborationGroup>();
Id currentUserId = UserInfor.getUserId();
List<GroupMember> lstGroupMember = [SELECT GroupId,UserOrGroupId FROM GroupMember where userorgroupid =:currentUserId];
for(GroupMember gm : lstGroupMember){
setGroupMemberId.add(gm.GroupId); //this set will give you set of all Groups
}
if(setGroupMemberId.size() > 0)
lstGroup = [SELECT Id,Name FROM CollaborationGroup where Id in: setGroupMemberId]; //this list will give you list of all group records
Hi,
You can use below 2 line of codes:-
Query in second line will give you list of GroupMember, from this list you can get IDs of all Group and query Group object to get detail of group.
Hope it will help you!
Happy to help you!
Regards,
Digamber Prasad
Hi,
I have modified my above code snippet
Hope it will help you!
Happy to help you!
Regards,
Digamber Prasad