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
Maciej Król 28Maciej Król 28 

Get sharing settings (OWD) options in APEX

I develop application, part of which is implementing of OWD settings edition. First phase is to do it as it is on standard Sharing settings setup. As there are multiple options for standard object - is it achievable to get all possible settings for each standard object?
VinayVinay (Salesforce Developers) 
Hi Maciej,

As per my understanding you cannot get multiple object at one time.
SELECT Id, DefaultAccountAccess, DefaultContactAccess, DefaultLeadAccess, DefaultOpportunityAccess FROM Organization

However these settings can be retrieved using the Metadata API.

Please mark as Best Answer if above information was helpful.

Maciej Król 28Maciej Król 28
Hi Vinay.
Thanks but it doesn't answer my question. I want to get all possible options for each object, for example
Account -> Private, Read, ReadWrite
Contact -> ControlledByParent, Private, Read, ReadWrite
Lead -> Private, Read, ReadWrite, ReadWriteTransfer