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
M SreekanthM Sreekanth 

Way without sharing keyword is there in apex as already by default it is without sharing(system mode).

By default apex class will run on system mode(without Sharing) then way without sharing key word is there in apex what is the exact use of it,When it will need.Can any one elaborate with one example please
Best Answer chosen by M Sreekanth
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Sreekanth,

I guess the main use of making the class as without sharing is because of below.
  •  If a class isn’t declared as either with or without sharing, the current sharing rules remain in effect. This means that the class doesn’t enforce sharing rules except if it acquires sharing rules from another class. For example, if the class is called by another class that has sharing enforced, then sharing is enforced for the called class.
please find the help article (https://developer.salesforce.com/docs/atlas.en-us.198.0.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm) for the same.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,