1

I programmed a VF page and I put it inside a section of a custom object. Now when a user open one record and doesn't have the privileges to see the VF section, the system shows this page inside the section (image below): enter image description here

The VF's security settings are perfect, but I want when a user, who doesn't have the privileges, opens the record page, the system has to show only the message " Insufficient privileges....." without the sidebar and the header. How can I accomplish this? Thank you for help.

2
  • does your page have showheader = "false" and sidebar = "false" ? Commented Sep 22, 2016 at 10:43
  • yes, showheader and sidebar are false Commented Sep 22, 2016 at 10:51

3 Answers 3

1

I think the best way to show a nice (and customizable) error would be to give everybody (all profiles) access to the VF page, but customize the page in a way that the data is only shown to the profiles that should see it, and anybody else will see a custom error message or a blank area, whatever you prefer.

1
  • in other terms that is what I referred in my answer ;)
    – Himanshu
    Commented Sep 22, 2016 at 11:10
0

It's better 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.

Add following code in your error visualforce controller.

[SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE
UserId = [single ID] AND RecordId = [single ID]]
2
  • If I'm correct, the question is on access to a VF page, not to a record.. Commented Sep 22, 2016 at 11:05
  • yes is the vf page the problem, all the profile can see the record but only a few must see the Vf section Commented Sep 22, 2016 at 12:27
0

I would create different page layout for different profiles so user always sees what he is alloved to see

You must log in to answer this question.

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