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
Tim Jones 71Tim Jones 71 

Is there a way using Apex sharing to prevent a user from seeing a record that relates to them?

I have a custom object in Salesforce that manages folks in a non profit staff role.
We want to prevent users from seeing their own record in this one object.
Guessing an appex trigger and sharing rule is the only way to do this.
Is that a correct assumption, and can someone point me in the direction of a good resource to do that?
ShirishaShirisha (Salesforce Developers) 
Hi Tim,

Greetings!

Please be informed that the Sharing rules are automatic exceptions to org-wide defaults for particular groups of users, to give them access to records they don’t own or can’t normally see".

So,if you are trying to restrict the user to access the records own by them then this is not possible.

If you generally trying to hide the records then the you can simply remove the Read access on the Objects.

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri