5

Stage: We have a legacy codebase from another outsourcer. We're adopting it for SFDX now.

Several tests are now failing because they generate duplicate Contacts. We'd like to avoid rewriting those tests because we plan to get rid of them completely later in the project.

As a quick fix, we want to deactivate duplication rules on scratch orgs we use for CI test run.

I couldn't find any info on how to this through SFDX during or after scratch org provisioning. Maybe someone faced the same issue before or just knows somehow how to achieve this with SFDX CLI?

1
  • You could use puppeteer to enable or disable settings, we have been using this for a while, works quite nicely!
    – Raul
    Apr 23, 2019 at 14:03

1 Answer 1

6

You can include the duplicateRules in your sfdx project tree in a disabled state and when you push them to your new scratch org, they will disable them in your scratch org

Example:

\main\default\duplicateRules\Contact.Standard_Contact_Duplicate_Rule.duplicateRule-meta.xml

The contents of that file:

<?xml version="1.0" encoding="UTF-8"?>
<DuplicateRule xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <actionOnInsert>Allow</actionOnInsert>
    <actionOnUpdate>Allow</actionOnUpdate>
    <alertText>Duplicate Alert</alertText>
    <description>Duplicate rule for contact records.</description>
    <duplicateRuleFilter xsi:nil="true"/>
    <duplicateRuleMatchRules>
        <matchRuleSObjectType>Contact</matchRuleSObjectType>
        <matchingRule>Standard_Contact_Match_Rule_v1_1</matchingRule>
        <objectMapping xsi:nil="true"/>
    </duplicateRuleMatchRules>
    <isActive>false</isActive>
    <masterLabel>Standard Contact Duplicate Rule</masterLabel>
    <operationsOnInsert>Alert</operationsOnInsert>
    <operationsOnInsert>Report</operationsOnInsert>
    <operationsOnUpdate>Report</operationsOnUpdate>
    <securityOption>EnforceSharingRules</securityOption>
    <sortOrder>1</sortOrder>
</DuplicateRule>

Note the isActive element

You must log in to answer this question.

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