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
Hansel Pena 4Hansel Pena 4 

How to check for several users access on several records?

Hi, 

I need to do the following. I have an object in which I have a lookup to User field and also a lookup to Account. That field (The user one) when the record is going to be inserted I need check if the user in that field has access to the associated account to the record.
I know that could be used  UserRecordAccess object for this purpose. for one use is great, but the problem is that I need the code to work in bulk mode and if I use UserRecordAccess I am sure I will hit the SOQL limit in that process. 

So my question is, is there a way to check for several users in which each of them has a related account record that I need to verify its access to that account(I only need to check if the user with the matched account has at least read access to the record)?

I thought in checking the users and Accounts on AccountShare object and then if the user wasn't found there then check if the user belongs to any of the Groups that have access to the specific account, but by now it is kind of struggling process to do this. So might be helpful any ideas. 

Hope my question is clear. If it is not let me know.

Thanks for reading this.