+ Start a Discussion
anil Kumaranil Kumar 

sharing rules


If i dont wrire With sharing and without sharing in fornt of calss. what is the default for class?

Sagar PareekSagar Pareek
By default it will be without sharing.


+1 It is important to understand that in both cases (With or Without Sharing), Apex runs in System Mode, so it wouldn't respect things like Field Level Security.
Use With Sharing when the User has access to the records being updated via Role, Sharing Rules, Sales Teams any sort of sharing really.
Without Sharing is reserved for cases where the User does not have access to the records, but there is a need to update them based on user input.
Also the With / Without Sharing commutes and if a class doesn't have an explicit declaration, the sharing context of the calling class is inherited.