+ Start a Discussion
Rajesh ShahRajesh Shah 

Help: Page running in User mode and Controller in system mode.

I am building a Visualforce page for creating a case. Now there are fields in case which are read only for all profiles except System Adminstrator. I need the user to enter the value for this field and so I created my page with a controller and not a standard controller. Also in my controller I added the modifier as without sharing.


Now when I log in through another user, I still see the field as read only on the page. However from the controller I am able to insert value or update the field. I fail to understand this. It seems to me that the page is running in User mode following the user profile permissions and field level security while the controller is running in Sytem mode. Is this the intended behaviour or am I missing something?


How do I solve this? Has anybody faced a similar problem before? Please reply. This is very critical to the project I am doing.


The modifier "without sharing" tells Apex not to enforce the sharing rules for the currently logged in user, i.e. to run in a  system context.


If you change this to "with sharing" do you get the behaviour you require?

Rajesh ShahRajesh Shah

No. It doesnt has any affect.


I want a field that is read only to the user at the profile level to be editable in the visualforce page. However, when that field is used as input field, the field comes as read only even though the page has a custom controller and the controller has without sharing. Interestingly I am able to insert/update values for the field in the controller without any error.


Hello rajesh,

Did you get an answer to this?

In my case, i am just displaying certain fields using outPutText and still it is not showing up :(