We use in our org case sharing (Setup–>Security Controls–>Sharing Settings–>Case (Default Internal Access From Public Read/Write/Transfer to Private))
Wa want this sharing settings in place when we create our scratch orgs, Is there a way to achieve that by sfdx cli command or some config in the project-scratch-def.json file?
After some searches, i have locate the information by SOQL:
Organization o = [Select DefaultCaseAccess from Organization];
But i can't update it by apex code for example
o.DefaultCaseAccess = 'None';
The field is not writable:
Field is not writeable: Organization.DefaultCaseAccess
Thank you for your help;
Best Answer
Probably a bit late but better than never.
You can use sfdx force:mdapi:deploy -d data/standard-object-stub/ -w 1 -u $SCRATCH_ORG_ALIAS with a package.xml that references a Case.object file with the following content in a objects subfolder before you deploy your sources
This will only change the sharing setting, which will take some time so you might want to delay the further steps like package installation or source push a bit.
Update 12/2019:
Within the topic of unlocked packaged (that might have managed packages with certain OWD sharing settings as a dependency) I've come across a probably interesting known issue in this field:
success.salesforce.com/issues_view?id=a1p3A000001SGtdQAG
That known issue raises hopes on better support for changing OWD sharing settings based on scratch org definition files.
Update 09/2020:
Actually that got improved recently, you can use the scratch org definition file: