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.
project-scratch-def.json
{
"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"
}
}
}