The most confusing and always been part of discussion where the answer is not satisfactory!
With sharing & Without sharing in Apex.
Remember theses points:
With sharing & Without sharing in Apex.
Remember theses points:
- If nothing mentioned in class then default is "Without sharing".
- If nothing defined in class and called within other class then it will execute with calling class's sharing setting accordingly.
- The sharing setting applies to all code contained with in the class, including initialization code, constructors, and methods.
- Inner classes do not inherit the sharing setting from their container class.
- 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.
- The 'without sharing' keyword is to ensure that the sharing rules (not permissions) for the current user are not enforced.
- The with sharing keyword allows you to specify that the sharing rules (and not permissions) for the current user be taken into account for a class. You have to explicitly set this keyword for the class because Apex code runs in system mode.
Great and useful post. I really got more information from your webpage. This sales force concepts was really helpful.
ReplyDeleteRegards,
Salesforce Training in Chennai | Salesforce course in Chennai