INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: insufficient access rights on cross-reference id: []
You can use userRecordAccess
object to check CRUD
permissions..
So pass the recordId and userId.. to check that user having what type of access on that record..
you can check variables like HasDeleteAccess
. If HasDeleteAccess
true means user have delete access. If false then user don't have access..
Based on these accessibility perform DML..
List<UserRecordAccess> lstUserRecordAccess = [SELECT RecordId,MaxAccessLevel,HasAllAccess,
HasDeleteAccess,
HasEditAccess,
HasReadAccess,
HasTransferAccess
FROM UserRecordAccess
WHERE UserId = '00550000000rlrX'
AND RecordId = '0015000000TaWdI'];