I am using CLI to create Scratch Orgs based from a definition file. The objective is to enable ContactsToMultipleAccounts when pushing our source data.

The issue, is the Scratch Org is being created with Allow users to relate a contact to multiple accounts being checked in the Account Settings. However, the Account Contact Relationship object isn't being created. I'm also unable to see the what-should-have-been-created correct Related Lists on the Account and Contact page layouts.

Because of this, when pushing my metadata into the org after creation, I'm getting deployment failures as there are data dependencies on that object.

A manual fix, is to manually uncheck this option in config, and recheck before pushing. But I still believe this to be unintended behaviour.

I have enabled ContactsToMultipleAccounts in both the 'features' section, but also as an 'accountSettings' option in the project-scratch-def.json file.

How can I ensure that the setting acts as expected on creation of a scratch org? Rather than requiring the manual step

Really appreciated

Step 1. Command to create Scratch Org sfdx force:org:create -s -f config/project-scratch-def.json --setdefaultusername -d 7 -a contactToMultipleAccountEnabled

At this point, I am expecting the Account Contact Relationship object to be created successfully

Step 2. Command to push my source sfdx force:source:push -f

*Now the deployment will fail unless I manually uncheck & recheck the Allow users to relate a contact to multiple accounts option in Account Settings as part of Step 1.


"orgName": "Scratch Org",
"edition": "Enterprise",
"features": ["EnableSetPasswordInApi", "SharedActivities", "DefaultWorkflowUser", "ContactsToMultipleAccounts", "LiveAgent", "ServiceCloud", "WorkplaceCommandCenterUser", "CaseClassification", "Entitlements", "CaseClassification"],
"settings": {
  "lightningExperienceSettings": {
    "enableS1DesktopEnabled": true
  "accountSettings" : {
    "enableRelateContactToMultipleAccounts" : true
  "mobileSettings": {
    "enableS1EncryptedStoragePref2": false
  "caseSettings": {
    "emailToCase": {
      "enableEmailToCase": true
  "quoteSettings": {
    "enableQuote" : true
  "entitlementSettings": {
    "enableEntitlements": true
  "emailAdministrationSettings": {
    "enableEnhancedEmailEnabled": true
"objectSettings" : {
  "opportunity": {
    "sharingModel" : "private"
  "case": {
    "sharingModel" : "private"


  • What version of SFDX do you have, and have you disabled REST deploys? – David Reed Apr 25 at 23:17
  • @DavidReed SFDX Version - sfdx-cli/7.98.0 win32-x64 node-v14.15.3. Rest Deploy is set to TRUE. Are you saying it could be related to metadata API misbehaving on restDeployment? – David Picksley Apr 26 at 8:17
  • @DavidReed I disabled this using the documentation provided and retried the steps, still had failures unfortunately – David Picksley Apr 26 at 8:27

After a few days of on-and-off testing, and reporting to Salesforce as a valid bug. The issue is somewhat intermittent, 3/10 times the org behaves as expected. 7/10 times it fails.


My solution going forwards (until this is fixed).

Fix for People:

  • Use Individual Scratch Orgs
  • Before pushing metadata into Org, manually re-enable the Account Setting

Fix for Pipeline:

  • Take advantage of using dedicated Sandboxes rather than Scratch orgs for now.

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.