If a user clicks 'Edit' on an opportunity which he isn't allowed to edit, the "Insufficient Privileges" page directly appears. This is good. If a user clicks 'Edit' on a custom object (which has an edit override that points to a visualforce page), he first sees the form without problems, and the "Insufficient Privileges" page only appears when he tries to save it. This behaviour is misleading for the users, because they think they can manipulate the data and put effort into it, and only afterwards they realize that this wasn't possible after all.

An idea was to check at page load if the user has edit permissions and otherwise redirect him to the "Insufficient Privileges" page.

Might there be another way? Thanks!

2 Answers 2


You can query the UserRecordAccess object to find out if a particular user has edit access to a record. Something like this should tell you if the particular user has edit access to the particular record.

select RecordId, HasEditAccess from UserRecordAccess where UserId = :UserInfo.getUserId()
and RecordId = :id]

I wrote a blog article about this a while ago that has some more details.

  • This is awesome!
    – eyescream
    Commented Jan 29, 2013 at 19:20
  • This sounds like the most straight forward solution, also I wanted to try to avoid APEX code. Great job! Commented Feb 4, 2013 at 22:23

Security settings generally (Profiles + Permission Sets)

I'm going to copy-paste a bit from one of my old answers:

Anything you can do in VF with {!$ObjectType.Opportunity.accessible} you can check with Opportunity.sObjectType.getDescribe().isAccessible()

Except in your case you'd be looking at isUpdateable. If it's false - block the access right away, easy :)

Edit rights to "this" particular record

Even if people can in general edit your objects, your org might be set up in a way that lets them edit only data they own for example (all other users' stuff is readonly).

You'd have to examine sharing settings and if the sharing model is complex - query the Opportunity__Share table. That one might be a bit tricky and you might have to waste several queries before you'll determine the access level. I'm going to be lazy again - check out Querying for OpportunityShare Rule

  • Thank you for this idea! But as you already mentioned this is only considering the profile's CRUD settings, not for specific records! I would love to go your way, because it would be easy to implement this in VF... Commented Feb 4, 2013 at 22:23

You must log in to answer this question.

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