Activity Forums Salesforce® Discussions In Salesforce, can I find out if the current user has access to a record without querying?

  • Vikas Kumar

    Member
    May 15, 2017 at 5:09 am

    Hi Saurabh,
    To find out if a particular user has Edit access to a record, use the UserRecordAccess object. This object is available in API version 24.0 and later. You can use SOQL to query this object to find out if the user has edit access to the record in question.

    SELECT RecordId FROM UserRecordAccess WHERE UserId=:UserInfo.getUserId() AND HasReadAccess = true AND RecordId IN :allRecordIds LIMIT 200

    Hope it may helps you

    Thanks

     

  • shariq

    Member
    September 17, 2018 at 11:11 pm

    Hi,

    The solution that was released in Spring ’11 (version 24.0) solves for this in a very elegant way. Salesforce implemented a read-only object that you can use to query whether a user has access to a record. The object is appropriately called UserRecordAccess and provides a comprehensive summary of a user’s given access to a particular record. Because it is an object that is designed to be queried, it is very simple to plugin the user’s id and a record id (or set of record ids) and get a result.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos