Can OWD be imported/exported as metadata?
I'm currently trying to create a scratch org which reflects our ludicrously complicated production org which contains hundreds of Roles.
Upon deploying most of these, I get errors like:
Error src/roles/WhateverUser.role WMSportCustomerUser field integrity exception: unknown (Opportunity access level below organization default) I guess this means I need to correctly configure the OWD before these roles can be deployed. Is there any way to do this using metadata (preferably "mdapi" since we aren't ready to move to "source" yet)? Don’t know how to import OWD as metadata?
Yes. Each object has two fields, "sharing model" and "externalSharingModel". You can import and export these values between orgs. You'll find this setting in the CustomObject metadata. I personally use this method to set up the sharing model for standard and custom objects. There's some weird bugs around it sometimes, so some manual setup may still yet be required, but it mostly works okay. ... Read
Note: OWD stands for Organization-Wide Default (OWD). The Organization-Wide Default settings are the feature in Salesforce settings that allow you to specify that what all records can be accessed by which user is registered on the instance and also in which mode.