+ Start a Discussion
MigMig 

Company Wide Default Setting & Apex = ?

Hi all,

 

First of all, thanks for your help

 

The scenario :

 

- I've got an object with Public Read Only access.

- The Edit button for this object is overriden by a VisualForce Page

 

Everything works fine but when a user tries to edit someone else record, he can enter into the Edit Record VF page and when he tries to save it works .. but it shouldn't because it's Public Read Only.

 

 Are theApex classes above the company Wide default setting ? How can I solve this problem ?

 

For info : It's an upsert... 

 

Thanks in advance. 

Message Edited by Mig on 05-20-2009 03:26 PM
Best Answer chosen by Admin (Salesforce Developers) 
Richie DRichie D

I'd have a try at setting 'with sharing' in the custom controller and seeing if that helps.

 

You'd need this to override the 'profile settings' of the user and filter the actual records they can read and/or edit due to the sharing rules.

 

R.

All Answers

aalbertaalbert

Are you using a custom controller or controller extension? If so, the apex will run in System Mode and override the Public Read-Only Access. Link

 

To enforce the logged in user's access level, I think you want to use a controller extension along with a standard controller and use the standard controller's "save" action.

Richie DRichie D

I'd have a try at setting 'with sharing' in the custom controller and seeing if that helps.

 

You'd need this to override the 'profile settings' of the user and filter the actual records they can read and/or edit due to the sharing rules.

 

R.

This was selected as the best answer