1

While creation of scratch org in SFDX, sharing settings of account, contact, opportunity is public read write. I want to set it as private with configuration. Please help me.

1
  • For an initial push it won't work if any of your code depends on a OWD change. – Diego Jan 6 '20 at 14:28
2

I believe that this is not doable as part of the org configuration file (project-scratch-def.json). Instead, you'd make sure to include this as part of your source metadata, and push that as part of the initial setup.

In each of the .object metadata files, you'll see <sharingModel>ReadWrite</sharingModel> -- change that to <sharingModel>Private</sharingModel and you'll be in business.


In case you need them, these are the acceptable values for sharingModel

  • Private
  • Read
  • ReadWrite
  • ReadWriteTransfer
  • FullAccess
  • ControlledByParent
  • ControlledByCampaign
  • ControlledByLeadOrContact

For example, the User object supports Private and Read values. Accounts, opportunities, and custom objects support Private, Read and ReadWrite values. Campaign members support ControlledByCampaign and ControlledByLeadOrContact. (source)

1
  • +1 - as an additional note, the OWD change process takes a nonzero amount of time, so pushing source right after deploying these changes will often fail anyway. One needs to poll for the availability of the relevant sharing objects or wait several minutes. – David Reed Oct 3 '19 at 20:11
4

Actually that got improved recently, you can use the scratch org definition file:

{
  "orgName": "Scratch Org",
  "edition": "Developer",
  "language":"en_US",
  "features": [
    "AuthorApex",
    "ContactsToMultipleAccounts",
    "StateAndCountryPicklist"
  ],
  "settings": {
    "accountSettings": {
      "enableAccountTeams": true
    }
  },
  "objectSettings": {
    "opportunity": {
      "sharingModel": "private"
    },
    "account": {
      "sharingModel": "read"
    },
    "case": {
      "sharingModel": "read"
    },
    "contact": {
      "sharingModel": "private"
    }
  }
}

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.