3

I'm trying to change Lead sharing from Public Read/Write/Transfer to Public Read. However when I add the code below to the definition json file and deploy, nothing changes. Can anyone help?

"objectSettings": {
    "lead": {
    "sharingModel": "read",
    "defaultRecordType": "default"
    }
  }

1 Answer 1

9

objectSettings is defined in the Scratch Org Definition File, which applies when creating a new org via sfdx force:org:create.

These sharing settings are likely not applied when deploying code to your existing scratch org. If you want to include sharing settings in your deploy process, you could add a custom metadata definition file(s) that overrides the standard Lead object to an unpackaged directory in your project and deploy them.

Sharing Settings can be changed via the sharingModel and externalSharingModel attributes.

For example,

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <deploymentStatus>Deployed</deploymentStatus>
    <label>Lead</label>
    <pluralLabel>Leads</pluralLabel>
    <sharingModel>Read</sharingModel>
    <externalSharingModel>Private</externalSharingModel>
</CustomObject>
3
  • Thanks for the input Dan, much appreciated. I've just managed to get DX to reference the Lead.object-meta.xml and set it from there so in this instance I did not need to use metadata. Its good to know that it can be done that way for future reference though so thanks again.
    – Jay
    Commented Sep 4, 2020 at 10:18
  • ..and thanks for clarifying the use of the scratch org definition file, also very useful to know
    – Jay
    Commented Sep 4, 2020 at 10:19
  • What is the way to set external access from the scratch org definition file?
    – learner
    Commented Aug 24, 2022 at 19:53

You must log in to answer this question.

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