1

We want to update the <ComplianceGroup> attribute on thousands of fields based on a list that our Legal department maintains. If we could just deploy the object, field and ComplianceGroup value, it would be very easy to generate the XML:

<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
 <fields>
  <fullName>Street__c</fullName>
  <complianceGroup>PII</complianceGroup>
 </fields>
</CustomObject>

But the metadata API rejects that for lacking <fieldType>. And even if we include that (which Legal does not list) it overwrites Help Text and Description. We know we could retrieve everything, parse it, insert the attribute and deploy, but that's a lot of work.

Is there some alternate way that we could update metadata that would merge ComplianceGroup into existing fields?

1 Answer 1

4

We know we could retrieve everything, parse it, insert the attribute and deploy, but that's a lot of work.

This option may not be a lot less work, but the open source build tool my team owns (CumulusCI) includes a framework we call "Metadata ETL" for automating exactly this type of change.

Metadata ETL tasks extract a specified subset of metadata from the org, ensuring that you have a deployable copy of the current state, makes targeted changes to the XML metadata based on your configuration, and then redeploys the entire package back into the org.

There isn't an out-of-the-box Metadata ETL task in CumulusCI to set the complianceGroup facet, but we do have one to set the Help Text (inlineHelpText) on fields. Modifying that task to target complianceGroup instead would be a lot more straightforward than building a scripting solution from the beginning, and you wouldn't have to write any Xpath or XML parsing code since that's all handled for you.

The task's source code is on GitHub. What you'd need to do to adapt it would be:

  1. Install CumulusCI.
  2. Create a project with cci project init.
  3. Connect to your org (preferably a sandbox with cci org connect --sandbox).
  4. Copy the Python code above to yourproject/tasks/compliance.py.
  5. Revise the Python code to point at complianceGroup instead of inlineHelpText.
  6. Add a new entry to cumulusci.yml, something like
tasks:
    update_compliance_group:
        class_path: tasks.compliance.UpdateComplianceGroup
        options:
             - api_name: Account.Description
               compliance_group: PII
             - api_name: Account.Website
               compliance_group: PII
             # and so on - depends on exactly how you tweaked the Task

And finally, run the task against the sandbox:

cci task run update_compliance_group --org mysandbox
2
  • Nice. I would have had to recommend sfdx + awk or something. Having a product that actually has this sort of function in it is cool.
    – sfdcfox
    Commented Oct 16, 2020 at 20:11
  • We've found a lot of interesting use cases for it. It's also a way to safely deploy changes to StandardValueSet, for example, without overwriting existing customization in the target org.
    – David Reed
    Commented Oct 16, 2020 at 20:18

You must log in to answer this question.

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