Salesforce Fact #444 | Check record access in same SOQL
There is an object named UserRecordAccess using which we can get to know whether a particular user has specific access to one or more records. But do you know we can get that details while querying the actual object itself, no need to query the UserRecordAccess object separately.
For example, The below query on Account will return whether the current user has Edit access to the queried records or not:
SELECT Id, UserRecordAccess.HasEditAccess FROM Account.
Another cool thing is we can also get to know whether the user has access to related record as well. For example, The below query checks whether the current user has read access to the related account records while querying the contact records:
SELECT Id, Account.UserRecordAccess.HasReadAccess FROM Contact WHERE AccountId!=NULL
Comments
Post a Comment