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
Stefan UnfriedStefan Unfried 

VF data displayed access rights

We are using a VF Page to display the latest products invoiced of an Account. Those values are retrieved from the Sales Lines (Custom Object) which are set private. 

However, Users who can access the Account, can also see the VF Page (as they need it for their own Accounts) and at the moment also get data desplayed in the VF they shouldn't see. Is there a way to prevent users seeing data in the VF they shouldn't? 

Best Answer chosen by Stefan Unfried
Piyush Gautam 6Piyush Gautam 6
Hi Stefan Unfried,

If you have used a custom controller(Apex Class) for fetching the data into the visualforce page then use 'with sharing' keyword in Apex class.

Eg:
public with sharing class ClassName{
// Code here


If found helpful, mark as solved.

Thanks