A sharing rule exists in Account which under certain criteria shares the record with a Role.

Is there a way we can query AccountShare object or any other table to check what Roles are Accounts shared with?

The relatedId in Group object says "For Groups of type “Role,” the ID of the associated UserRole."

2 Answers 2


Yes sure.

You can use SOQL like bellow:

SELECT AccountAccessLevel , AccountId , CaseAccessLevel , ContactAccessLevel , Id , IsDeleted , LastModifiedById , LastModifiedDate , OpportunityAccessLevel , RowCause , UserOrGroupId FROM AccountShare WHERE RowCause = 'Rule'

This will give you all account rows those are shared to Role. If you are interested in perticuler role then you can add condition like AND WHERE UserOrGroupId = 'ROLE_ID_XXXX'


You can't directly get the Role id from the Single Query.

You need to query in such a way :

[select relatedid from Group where id in (SELECT UserOrGroupId FROM  customObject__Share where rowcause='Rule')]..

The RelatedId is the Id of role that has access/the role with the record is being shared.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .