3

Background: I have a problem where if I try to deploy my entire set of metadata to a newly created scratch org, it fails because the sharing settings of certain objects are incorrect by default, causing errors regarding AssetShare and OrderShare records not being available with the current sharing setup.

I can solve these issues by manually setting the sharing to the correct values, but I want to automate the entire process. I'm trying to deploy only the Asset and Order object metadata file first, containing only the sharing setting, like so:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">    
    <sharingModel>Read</sharingModel>
    <externalSharingModel>Private</externalSharingModel>
</CustomObject>

I want to set both regular sharing and external sharing, which I can do manually without any issues, but when I try to deploy I immediately get the response that the deploy Can't specify an external sharing model for Order (same thing for Asset)

I tried deploying the metadata without the externalsharing, but besides locking changes to the sharing for 15+ minutes, that only resulted in an email saying that changing the sharing was unsuccessful.

EDIT: Likely this is precisely because external sharing isn't being updated alongside it, because if I try to only edit the internal sharing and leave external as-is, I get an error in the UI saying The default external access must be more restrictive or equal to the default internal access.

  • This seems relevant salesforce.stackexchange.com/questions/266326/… – Charles T Nov 28 '19 at 12:59
  • Are you able to deploy an external sharing model for any sObject via the methodology you're currently using? Say Account, or a custom object? I've had success doing so but I have not tried it with either Asset or Order. – David Reed Nov 28 '19 at 21:22
  • @DavidReed Yes, I just did a test and I can deploy a change to the Account sharing settings like this – Valyrion Dec 2 '19 at 11:53
1
+100

In short: Order Sharing Settings have to be set via the UI.

Solution: try to build selenium automation for this, maybe have a start here.

So what makes me say this?

First of all let's have a look at the example scratch org setup I made: {

"orgName": "testorg",
"country": "US",
"language": "en-US",
"edition": "Developer",
"features": ["ExternalSharing"],
"settings": {
}

}

Then I tried deploying your specified object files, which were resulting in the stuck sharing calculation, in two different scratch orgs. On the other hand, just as you said already, manual setting works totally fine.

The other funny thing is, that if you try that with any other object than order, deploying works fine as well.

Well, it's not that much of information, but it is a confirmation that this is just the way it works and there is not much we could do about, except building the workaround with ui automation.

  • This is the answer I was afraid of. I'll add it to the growing pile of blocking issues for migrating to DX. – Valyrion Dec 4 '19 at 10:45
  • Yeah, Migration is tough, since there are a lot of things, which are either not applicable via any API or within these huge unexplained feature list for the definition file. But building the selenium infrastructure into a sfdx plugin definitly made our life a lot easier here. – Hyperzwerg Dec 5 '19 at 12:14

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.