• #42897
     Prachi #6
    Forcetalks

    Can I find out if the current user has access to a record without querying?

    Can I find out if the current user has access to a record without querying?

    #42899
    Forcetalks

    Hi Prachi,

    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, HasEditAccess FROM UserRecordAccess WHERE UserId = [single ID] AND RecordId = [single ID]

    If you want to check a batch of records you can use
    SELECT RecordId FROM UserRecordAccess WHERE UserId=:UserInfo.getUserId()
    AND HasReadAccess = true ANDRecordId IN :allRecordIds LIMIT 200
    But make sure that allRecordIds is a LIST of IDs. It doesn’t work if allRecordIds is a SET of IDs. I guess that’s a bug.
    Also, only a maximum amount of 200 recordIds can be checked in one query.

Viewing 2 posts - 1 through 2 (of 2 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?