We are trying to make quite a lot of changes to our existing role hierarchy.. (deleting , merging and adding new roles); As part of it, I am trying to find couple of things:

  1. Find all the sharing rules where records are shared with the Role that is impacted (I know the objects which I need to check example: Accouunshare, Opptyshare etc..) I need to identify them and update them with the new roles

  2. Find all the public groups where the impacted role is a member I need to identify them and update them with the new roles

Is there a way to query through workbench or any other tool to find this out...

3 Answers 3

  1. I am not sure if this request is feasible to make any more efficient than looking through the UI, but you may be able to find this information in Object Metadata if you have a Force.com IDE such as Eclipse.
  2. You can find this information through a query.


SELECT Id, RelatedId, Type FROM Group where RelatedId= :UserInfo.getUserRoleId()
List<Group> groupDetails =[Select Id from Group where RelatedId IN (Select Id from UserRole where PortalType='None')];

for(Group g:groupDetails){



And then use these groupId to query on your share object...


List<OpportunityShare> opptyShareList = [Select Id,OpportunityId,UserOrGroupId,RowCause,OpportunityAccessLevel from OpportunityShare where UserOrGroupId IN : groupId and RowCause='Manual'];

My best practice for this is to update role hierarchy in a Test or Sandbox environment first to see if there's any negative impact. And we can jot down all the steps we done to fix the sharing. Make a deployment guide when we apply the changes into production, follow it will save our life.

If you find yourself getting hard with a mess role hierarchy, i suggest you to check www.orgforce.io which visualize the whole hierarchy and update it by drag and drop. Save me a ton of time!

You must log in to answer this question.

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