One thought on “How to Fix Salesforce Deployment Errors: Platform Encryption cannot be enabled for standard fields when Portals are enabled.

  1. Hello I found a workaround solution in your scratch org definition file you can simply add the hasSampleData attribute to true like shown below and it will create your scratch without the portals enabled. It works for both org shape and for definition file only.

    ===========

    {

    “orgName”: “Feature Scratch Org”,

    “sourceOrg”: “idOfYourOrg”,

    “hasSampleData”: “true”,

    “features”: [“EnableSetPasswordInApi”],

    “settings”: {

    “lightningExperienceSettings”: {

    “enableS1DesktopEnabled”: true

    }

    }

    }

    If you want there is another work around you can also create your org with developer edition without using hasSampleData attribute. However if you need to use the enterprise edition you have to add the hasSampleData attribute to true.

    If you are not using orgshape your definition file should look somewhat like this:

    {
    “orgName”: “Feature Scratch Org”,
    “edition”: “Enterprise”,
    “hasSampleData”: “true”,
    “features”: [“PlatformEncryption”, “PersonAccounts”],
    “settings”: {
    “lightningExperienceSettings”: {
    “enableS1DesktopEnabled”: true,
    “enableUsersAreLightningOnly”: true
    },
    “platformEncryptionSettings”:{
    “enableDeterministicEncryption”:true,
    “enableEncryptFieldHistory”:true,
    “enableEncryptionSearchEnabled”:true,
    “enableEventBusEncryption”:true
    }
    }
    }

    In case you are using it in a CDCI use case you can also include your encryption settings in the file PlatformEncryption.settings-meta.xml as shown below:

    ======== PlatformEncryption.settings-meta.xml =====

    true

    true

    ===========================================

    and you can generate your tenant keys via sfdx automatically using the following commands:

    – sfdx force:data:record:create -s TenantSecret -v “Description=scratchOrgTest”

    – sfdx force:data:record:create -s TenantSecret -v “Description=scratchOrgTest Type=SearchIndex”

    – sfdx force:data:record:create -s TenantSecret -v “Description=scratchOrgTest Type=DeterministicData”

    – sfdx force:data:record:create -s TenantSecret -v “Description=scratchOrgTest Type=EventBus”

Leave a Reply

Your email address will not be published. Required fields are marked *