Activity Forums Salesforce® Discussions How can I find whether the current user has access to a record without querying in Salesforce?

  • Subhendu

    Member
    January 16, 2018 at 12:21 pm

    Hi Ratnakar,

    As far as I know, you need to make a query on UserRecordAccess with UserId and Record Id to find if the record is accessible by the user. You can think of using describeSObject and check for access, but it will provide you access details on Object level not record level.

    There is another approach, not sure if it's the best solution but you won't need to make a query in this approach. You can create a with sharing class and create database Savepoint in it then try to update and delete the record. Check for errors in both the operations and then rollback to the savepoint. If the user does not have record access you will get an error. As I said earlier, I do not recommend this approach and as per my understanding, the best way is to make a query.

    Hope this helps.

    Thanks,
    Subhendu

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos