function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Samruddhi GokhaleSamruddhi Gokhale 

How to get roleId from GroupMember?

My group has all the users with a specific name. I have tried below query:
select group.relatedId from GroupMember where id = '<my group id>'
Though my group is related to a single role, I still get null in relatedid. What is the reason?
NagaNaga (Salesforce Developers) 
Hi Samruddhi,

Can you use    "select RelatedId from group" and see if its working, it should work as per me.

Best Regards
Naga Kiran
Samruddhi GokhaleSamruddhi Gokhale
That as well is not working. Null value is returned.
ManojjenaManojjena
Hi Samruddhi,

You can not get the RelatedId in groupmember .You can get the Group.Name and other Group Fields .

To get the roleId you need to query from user with the userid related to GroupMember .And you canget the role id from User .

 
Samruddhi GokhaleSamruddhi Gokhale
The problem is, I do not get userId from groupMember as the user is not part of that group directly. 
ManojjenaManojjena
Hi Samruddhi,

You can check the below link. May be due to the many to many relationship we ar enot getting the relatedid in GroupMember .

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_erd_users.htm  

Let m eknow your view .
Samruddhi GokhaleSamruddhi Gokhale
Yes you are right. But there should have been a junction object between userRole and GroupMember. I am not getting how other people get the users of a particular group in this scenario.