I'm trying to find the sharing settings OWD information and I have looked at the tooling/api and APEX/SOQL could not find, is that even possible to retrieve this metadata information?

enter image description here


To get the sharing model for standard objects, and to get access to sharing rules, you need the Metadata API. The objects you're interested in are SharingRules and CustomObject's sharingModel attribute. The Tooling API lets you query the sharing model for custom objects, and the Organization object in SOQL lets you query the default sharing model for Accounts, Contacts, Opportunities, and Cases, but not much else. The Metadata API should be considered your one-stop shop for getting all the information you need.


There's a better way to get this from apex directly without callouts now!

List<EntityDefinition> eds = [SELECT DeveloperName, ExternalSharingModel, InternalSharingModel FROM EntityDefinition];

Documented here https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_entitydefinition.htm but works in normal apex/soql!

  • Even for custom objects ? – Nick Kahn May 29 '20 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.