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)?

1 Answer 1


Yes. Each object has two fields, "sharingModel" 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.

<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">

You must log in to answer this question.

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