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
Ankit Gupta SFDCLearnerAnkit Gupta SFDCLearner 

withsharing and without sharing

Hello Friends, 
I have 3 Classes in attached Image

a) abc()  Normal,
b) Efg() is with sharing
c) xyz() is without sharing


What happened if we are calling other class methods in any class, will all methods run in the calling class mode or it will run accordingly to it’s own class behavior.


User-added image
Gururaj BGururaj B
The method executes with the sharing rule that is definied in its class and not of the class that is calling the method. In your example:
1. efg method executes with sharing and xyz class executes without sharing when its called from class abc.
2. xyz method executes without sharing and abc class without sharing when its called from class efg
3. efg method exeuctes with sharing and abc class without sharing when its called from class xyz.

Please mark as best answer if it answered your question.

Thanks
 
Ankit Gupta SFDCLearnerAnkit Gupta SFDCLearner
Thanks 
Gururaj B