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
Salesforce_NikitaSalesforce_Nikita 

Visual force with Permission Sets

I have created permission set for a user and assigned it.
The user does not have view all/,odify all for the object
When I see results on visualforce page , it brings back ll the records,
Cn you suggest a solution ?
Bhanu MaheshBhanu Mahesh
Hi Nikita,

Check what is the access level set for the controller (with sharing or without sharing)

Use the with sharing or without sharing keywords on a class to specify whether or not to enforce sharing rules.

By default apex runs in system context that is without sharing.

The with sharing keyword allows you to specify that the sharing rules for the current user be taken into account for a class. You have to explicitly set this keyword for the class because Apex code runs in system context. In system context, Apex code has access to all objects and fields— object permissions, field-level security, sharing rules aren’t applied for the current user. This is to ensure that code won’t fail to run because of hidden fields or objects for a user. 

Use with sharing in your constructor to restrict the results to only to the records the user have access.
 
public with sharing class sharingClass {

// Code here

}

Refer the below link
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm

Mark this as "SOLVED" if your query is answered

Thanks & Regards,
Bhanu Mahesh Gadi
Salesforce_NikitaSalesforce_Nikita
The backend controller is public with sharing class. 
Can you suggest an alternative?
Bhanu MaheshBhanu Mahesh
Check the OWD for the object. If it is public then all the users have access to all the records the object.

Also please check whether there are any sharing rules on the object that shares the records withe user.

Check what is the role of the user, if the role is higher in the heirarchy, he will have access to all the records that belongs to the users who are below in the heirarchy

Thanks & Regards,
Bhanu Mahesh Gadi