5

Is there any way how to automatically enable "Data Protection and Privacy" option during creation of scratch org (in definition file)?

Data Protection and Privacy

I didn't found any mention about this metadata in Metadata API at all. Is it already supported?

We have implemented some logic that is dependent on Individual object and I can't push converted dx source into scratch org with this option disabled.

2 Answers 2

2

You can set this inside the org preferences.

OrgPreference.settings-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<OrgPreferenceSettings xmlns="http://soap.sforce.com/2006/04/metadata">
    <preferences>
        <settingName>ConsentManagementEnabled</settingName>
        <settingValue>true</settingValue>
    </preferences>
</OrgPreferenceSettings>

Easiest way to get this file is to add it to your package.xml under Settings if you are pulling from a sandbox or to actually create it as above and push into a scratch org - when you pull you should get all the other settings in there as well.

4
  • Adding this file causes my push to fail against my scratch org. Is this the correct format? Jun 17, 2019 at 21:25
  • Edited above to show how the whole file would look like and how to pull/retrieve this from a sandbox or scratch org. Jun 19, 2019 at 7:49
  • This was perfect, I wish I could mark the answer as accepted for the OP. Thank you! Jun 19, 2019 at 17:08
  • Glad I could help! Jun 20, 2019 at 11:28
2

The Data Protection and Privacy preference can be automatically enabled via the scratch org definition file (e.g. project-scratch-def.json) using the settings.orgPreferenceSettings.consentManagementEnabled property.

{
    ...
    "settings: {
        "orgPreferenceSettings": {
            "consentManagementEnabled": true
        }
    },
    ...
}


However, according to the Winter '20 Release Notes, the ConsentManagementEnabled field on the OrgPreferenceSettings metadata type will be moved to enableConsentManagementEnabled on PartyDataModelSettings instead, so be sure to update your configuration file in the future.

{
    ...
    "settings: {
        "partyDataModelSettings": {
            "enableConsentManagementEnabled": true
        }
    },
    ...
}


The ability to define org preferences in the scratch org definition file is available in Winter ’19 and later. This is detailed in the Scratch Org Settings section of the Scratch Org Definition Configuration Values documentation. You can also find a list all settings in the Settings Metadata API documentation. Be sure to use lower-case camel case when adding to the scratch org definition file.

1
  • One additional note is that if you use Individual object on another metadata like contact object's page layout as a look field, you need to deploy the PartyDataModel setting first in a separate deployment. Then you can push your changes related with the Individual object with a second deployment.
    – Kenan Ce
    Sep 20, 2023 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .