Salesforce provide UserRecordAccess object to identify access of user on set of records. We can query on this object based on user ID.
Key Points of UserRecordAccess
Fields of UserRecordAccess
Sample Query
SELECT RecordId, HasEditAccess,HasReadAccess, HasTransferAccess, MaxAccessLevel,HasDeleteAccess
References
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_userrecordaccess.htm
https://help.salesforce.com/articleView?id=000181207&type=1
Key Points of UserRecordAccess
- This object is read only.
- It is available in API Version 24.0 and later.
Fields of UserRecordAccess
- RecordId - Id of record in which we need to check access, It is available in SELECT clause and WHERE clause.
- UserId - It is available in WHERE clause.
- User Record Access Id - It is available in WHERE clause.
- Maximum Access Level - It is used to identify maximum access of record having user(Picklist type). Value available in picklist.
- None
- Read
- Edit
- Delete
- Transfer
- All
- HasTransferAccess(Boolean Type)
- HasEditAccess(Boolean Type)
- HasDeleteAccess(Boolean Type)
- HasAllAccess(Boolean Type)
Sample Query
SELECT RecordId, HasEditAccess,HasReadAccess, HasTransferAccess, MaxAccessLevel,HasDeleteAccess
,HasAllAccess FROM UserRecordAccess
WHERE UserId = UserInfo.getUserId()
AND RecordId = :recordId
References
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_userrecordaccess.htm
https://help.salesforce.com/articleView?id=000181207&type=1