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
sandeep reddy 37sandeep reddy 37 

using with sharing key word

using with sharing key word  but owd sharing rules =private 
how can we get record and is it accesble or not if yes or no how please tell me 
 
JyothsnaJyothsna (Salesforce Developers) 
Hi Sandeep,

Setting an object to Private makes those records visible only to record owners and those above them in the role hierarchy.
Use the Grant Access Using Hierarchies checkbox to disable access to records to users above the record owner in the hierarchy for custom objects 
in Professional, Enterprise, Unlimited, Performance, and Developer Edition. If you deselect this checkbox for a custom object, only the record owner and users granted access by the organization-wide defaults receive access to the records.

Sharing rules
can only be used to grant additional access—they cannot be used to restrict access to records beyond what was originally specified with the organization-wide sharing defaults.

With sharing Keyword:
 This keyword enforces sharing rules that apply to the current user. If absent, the code is run under default system context.

With Sharing keyword implies in another word, "with Security Settings enforced". This again pertains to only respecting OWDs and Sharing Rules.

Using with sharing keyword only record owner and those above them in the role hierarchy will access the records.
 
Hope this helps you!
Best Regards,
Jyothsna