The problem is that I cannot set the role for the scratch org user. I get the following error:
Unable to Finish Processing Request
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact [email protected]. Please indicate the URL of the page you were requesting as well as any other related information. We apologize for the inconvenience.
Thank you again for your patience and assistance. And thanks for using salesforce.com!
Error ID: 1017403518-10359 (91723303)
I've used the SFDX CLI to create a scratch org using the following JSON definition (though with a real namespace linked to the dev hub):
{
"orgName": "Demo",
"edition": "Developer",
"namespace": "example",
"features": [
"AddCustomApps:30",
"AddCustomTabs:30",
"AddHistoryFieldsPerEntity:25",
"API",
"AuthorApex",
"Communities",
"DebugApex",
"ExternalSharing",
"LightningSalesConsole",
"LightningServiceConsole",
"MaxApexCodeSize:10",
"MaxCustomLabels:15",
"ProcessBuilder",
"Sites",
"Workflow"
],
"settings":{
"orgPreferenceSettings":{
"networksEnabled": true,
"chatterEnabled": true,
"enhancedEmailEnabled": true
},
"nameSettings":{
"enableMiddleName": true
}
}
}
The command itself was:
sfdx force:org:create -f the-above-file.json -asomealias -d7 --setdefaultusername country=GB language=en_US
This appears to work fine and I can access the org using the CLI command:
sfdx force:org:open -u somealias
I then pushed my code to the org and tried to run all my tests. Some tests failed. These were consistently those that tried to use System.runAs.
The specific error message either:
Internal Salesforce Error: 196804881-4926 (650451209) (650451209)
Or, more enlighteningly:
System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, portal account owner must have a role: []
It was the latter that took me to the scratch org user's configuration where I spotted that no role was set.
Using the standard Salesforce UI I attempted to set this user's role to CEO, but on clicking Save I got the error shown at the start of this question.
Anyone got any ideas as to how to resolve this problem?