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
anil Kumaranil Kumar 

sharing rules

Hi,

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

Regards,
Anil
Sagar PareekSagar Pareek
By default it will be without sharing.

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_keywords_sharing.htm

007rakeshistom007rakeshistom
+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.

Rakesh