function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nitesh ..Nitesh .. 

question about visualforce sharing

This is one of the exam qns I have seen around that I don't agree with the answers I have seen:
A developer needs to create a visualforce page that displays case data. The page will be used by both support reps and support managers. The support rep profile does not allow visibility of the customer_Satisfaction_c Field, but the support manager profile does. How can the developer create the page to enforce field level security and keep future maintenance to a minimum?

A. Create one visualforce page for use by both profiles

B. Use a custom controller that has the with sharing keywords

C. Use a new support manager permission sets

D. Create a separate visualforce page for each profile

Now everywhere the answer suggested is B. But I am wondering why it is not A? By deafault the standard controller will impose user level sharing (rather than custom's system level sharing). This would also need less maintenance because there is no need to create an extension (with the 'sharing' keyword).

Can someone explain why it can't be A? or confirm it is A? (ofcourse B will also work but it is extra development that, IMHO, is not needed)
ROHIT SRIRAMA 3ROHIT SRIRAMA 3
Nitesh,
I see option A works well.
We can use rendered attribute on the VF page custom field.
Based on profile type check in rendered attribute we can make field visible or not.
Hope this helps!!
Rahul Garg SFDRahul Garg SFD
I think Field Level security is independent of with sharing keyword, as sharing rules are the part of record Level security and not Field Level Securty. 

To restrict a profile so that a particular field is not visible to it, we can just change the Field Level security settings for a particular object in profile.
Parikhit SarkarParikhit Sarkar
The developer can create the page to enforce field level security and keep future maintenance to a minimum by using a new support manager permission sets.

By using these permission sets the developer will create a visual force page that displays case data and the page will be used by both support reps and support managers. 
Rajesh KanikeRajesh Kanike
Question is to enforce field level security with minimum maintenance:

I agree with Option A.
as per my undestanding "With Sharing" keyword can impact data visibility and nothing to do with field visibility.