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
Ganesh GuptaGanesh Gupta 

How can I access organization wide secuirty(Public/Private) of Object(Account) in the Apex?

I have written Apex code to support custom functionality for all objects. As I need to perform common task according to organization wide defaut secuirty(Public/Private) of object.

 

Is there any way to dynamically know the OWD of the object with in the Apex class. So I do not need to change the code, if any object OWD permission get changed.

 

Thanks in advance.

Ganesh

vck01vck01

By default all the apex classes run in system mode irrespective of the Securtiy settings provided. Salesforce provides us a feature to enforce security and sharing rules for the user using a record usng two keywords "With sharing" and "without sharing"

 

If "with sharing " is used with the class ,all the security rules and automatically enforced for the object based on the profile settings(for respective users)

 

Please see the below link for more details:

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

 

 

 

Regards,

Chaitanya