I have a batch job that process 100 records at a time. During this process it attempts to find and assign ownership of the record to a given user based on different criteria. My problem is that occasionally a user defined in the matching table may no longer be active or set to have access to a record. So even though it allows me to set the owner to the user, it crashes during the update because the new owner of one of the records doesn't have read access.
You can check multiple records at a time, but for only one user.
SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId = [single ID] AND RecordId = [single ID] or [set of record ids]
But I need to check multiple users and multiple records. For example I need to check that User A has access to record A and User B has access to record B and User C has access to record C. So I would have to run the above query 3 times to check all 3. Which is fine, but I may have up to 100 pairs to check. So 100 queries is not possible. Does anyone know of a way to check multiple records and users at the same time, with one query?