+ Start a Discussion
sfdc freshersfdc fresher 

what is the significance of with out sharing

hi everyone,

why we need to mention without sharing keyword, eventhough by default it is without sharing
v varaprasadv varaprasad
Hi,

Even though a class without any sharing keyword by default is without sharing, the calling class will determine.

If a with sharing class calls a class without any sharing keywords, then sharing rules are enforced.

If a with sharing class calls a class with without sharing a keyword, then sharing rules are not enforced.

Please check once below URLs: 

https://pritamshekhawat.wordpress.com/2015/07/13/with-sharing-without-sharing-keywords-in-apex/
https://www.salesforcetutorial.com/with-sharing-without-sharing-keywords/


Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Thanks
Varaprasad
@For Salesforce Project Support: varaprasad4sfdc@gmail.com

Salesforce latest interview questions  :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1





 
Nandigam RajeshNandigam Rajesh
Hi,

By defaults all the apex class are determined as without sharing. The main agenda to use the keyword with sharing and without sharing is as followed :
If a with sharing class calls a class without any sharing keywords, then sharing rules are enforced.

If a with sharing class calls a class with without sharing a keyword, then sharing rules are not enforced.


Regards
Rajesh