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

isAccessible() also respects sharing rules ?

I have a VF page with a controller. The controller executes a SOQL query and renders the result in the VF page. Straightforward.
I certainly want to respect sharing rules and FLS. This article describes the FLS part using the isAccessible() method. Another article states that using "with sharing" in the class definition will automatically respect the sharing rules when a SOQL query is executed in the class. Now here comes the surprise:
When I have sharing rules set up for opportunities, I first have to make the opportunities Private in the sharing settings of my org (see Surprisingly as soon as I do that, the isAccessible() method returns false for every field on the opportunity even if a certain profile actually has access to the fields. Does that make any sense? So as soon as a user actually has access to a record according to the sharing settings, the FLS check in my code would not allow access to any field of the object. How can I solve that?

Any ideas? Thanks

Richard BlakeRichard Blake
From my experience I think isAccessible() only respects field level CRUD. i.e, is Read permission is checked. Similarly isUpdateable() is only true when Edit permission is checked.