+ 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,
 

All Answers

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,
 
This was selected as the best answer
akr connectakr connect
hey guys you written an awesome content on your website blog keep post more content on differ sites so you can find new trrafic on your website. looking for best ortho treatment in kanpur at one place visit now knee replacement surgeon in kanpur (https://aakaarbonecare.com/knee-replacement/) hip replacement surgeon in kanpur (https://aakaarbonecare.com/hip-replacement-surgeon-in-kanpur) best orthopedic clinic in kanpur (https://aakaarbonecare.com) to know all the details about the best orthopedic treatrment in kanpur india.
Maive CarryMaive Carry