0

Related to System.runAs for CspLitePortal Profile Users recently started returning no rows, I am now wondering how to automate the setting of the external sharing model for some SObjects contained in managed packages that we automatically install in our CI scratch org.

My first thought was to use:

sfdx force:source:deploy --sourcepath config-components/externalSharingModel

to deploy just those flags for the relevant SObjects:

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

but multiple other attributes seem to be required.

Is there a simple way to set the external sharing model values in a scratch org programmatically?

(All I can think of is read/modify/write via e.g. the apex-mdapi.)

0

I've taken the simple approach here of establishing what the minimum CustomObject definition that will deploy is and it is typically:

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <deploymentStatus>Deployed</deploymentStatus>   
    <externalSharingModel>ReadWrite</externalSharingModel>
    <label>Invoice</label>
    <nameField>
        <label>Invoice Number</label>
        <type>Text</type>
    </nameField>
    <pluralLabel>Invoices</pluralLabel>
    <sharingModel>ReadWrite</sharingModel>
</CustomObject>

with the build deploying these via a single:

sfdx force:source:deploy --sourcepath config-components/externalSharingModel

Tedious to create the files but only needs doing once.

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.