2

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

2 Answers 2

3

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.

5

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!

2
  • Even for custom objects ?
    – Nick
    May 29, 2020 at 18:47
  • @Nick yes. Mike Tetlow: Thanks!
    – TheShadow
    Apr 23 at 6:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .