Play Games

Search This Blog

Thursday, February 4, 2021

How to check if a record has access to the logged in user using SOQL query - Salesforce Globe For You

 How to check if a record has access to the logged in user using SOQL query?  - Salesforce Globe For You 

Problem: Assume a record exists in system,want to check if particular user has read,edit or delete access to that particular record.

Solution: use SOQL query as given below

SELECT RecordId , HasDeleteAccess , HasEditAccess , HasTransferAccess ,HasReadAccess from UserRecordAccess where RecordId=:recordId and UserId=:userId

where recordId is the salesforce recordId and userId is the userId of the user.

Example:Assume '0000000000' is the recordId and '00000000000' is the userId

SELECT RecordId , HasDeleteAccess , HasEditAccess , HasTransferAccess ,HasReadAccess from UserRecordAccess where RecordId='00000000000' and UserId='00000000000'

Output:



No comments:

Post a Comment