4

Is it possible to check if I (current SF user) can update a given object instance?

We can use Schema.sObjectType.Contact.isUpdatable() to check if the current user has permissions to update Contact objects in general (Please correct me if I'm wrong).

However, it's possible that we might come across another Contact instance (EDIT: i.e a record) which we can not update because it's owned by someone else.

My question is, can I check if a particular standard object instance (EDIT: i.e a record) is updatable instead of checking on the class in general?

2
  • 2
    Do you want to check if a particular record is updateable by a user?? Then you should check the share table table for that object.. The line Schema.sObjectType.Contact.isUpdatable() will result true if the current user's profile has EDIT permission on the contact object
    – Sam
    Commented Sep 23, 2013 at 15:03
  • Yes, that's exactly what I want! Would it be possible for you to give a quick example, or a link to such as I'm pretty new with SF, ideally as an answer.
    – BuddhiP
    Commented Sep 23, 2013 at 15:05

2 Answers 2

6

You can query the UserRecordAccess table (documentation is here) to find out what permissions a particular user has on a particular record of an object. This table allows you to construct the following query:

SELECT RecordId, HasEditAccess
FROM UserRecordAccess
WHERE UserId = :UserInfo.getUserId()
AND RecordId = <<record Id>> 
0

You can also build a custom sharing button for each object to help make UserRecordAccess accessible in a non-programmatic way. Check out the custom sharing button blog post on salesforcehacker - http://www.salesforcehacker.com/2013/09/build-your-own-custom-sharing-button.html.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .