We're working on an app where we need to display the records if user has access to it. We're following below given algorithm:
- If User's profile has View All permission then display all records.
- If User's profile has View All permission on specific object then display all records of that object.
- If sharing setting is Public * or more than Public then show all records of that object.
If sharing setting is private then:
a). If user is added as member on MyCustomObject __Share then display record.
b). If user belongs to a group and and that group has access to this record then display record.
Problem is at point 4-b) when we check group is added in MyCustomObject __Share then make the record visible to it's member. But problem is that when group is standard one "Internal User" - Query
select UserOrGroupId from MyCustomObject __Share does return Id of group "All Internal Users". But when we query to find out member based on that Id like
select id, UserOrGroupId from GroupMember where GroupId = '00G9xxxxxxxxx' it does not return any result. When we query on Group we find a group with type "Organization".
So, question is how can we make sure that a user belongs to this standard group? I read through doc (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_group.htm), it says:
Organization—Public group that includes all the User records in the organization. This group is read-only.
Is it safe to assume that if this group is added on record then show this record to all internal user?
Please feel free to provide a better suggestion if you have.
Please note that we can not use UserRecordAccess because it has some limitation lie works only 200 records ....works only in context with current user if you query it on specific object.