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...

  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'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.