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
inbox outbox 7inbox outbox 7 

I would like to know how the sharing context work based on the below scenario.

I never came across this scenario and I need your input. 

You have a class with sharing, you have another class without sharing, without sharing class is callig a method in with sharing class, how does the sharing context work?


 
Best Answer chosen by inbox outbox 7
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

The behavior would be based on the class which the method is present . 
For example:

If a with sharing class calls a without sharing class, then the called method(s) will be executed in the mode of the class in which they were defined, in this case, the called method(s) will execute in without sharing mode.

https://learn-force.com/2019/08/26/understanding-sharing-in-apex-class/#:~:text=If%20a%20with%20sharing%20class,execute%20in%20without%20sharing%20mode.
If this solution helps, Please mark it as best answer.

Thanks,