4

I've found how to reference Matching Rules by name in Metadata, but that's only the logic to identify a duplicate. I'm looking for how to reference Duplicate Rules by name in Metadata, which will dictate what to do when a duplicate is found.

Does anyone know if it's supported in Metadata yet, and if so what's the name to reference it?

XML from retrieving

<types>
    <members>*</members>
    <name>MatchingRule</name>
</types>

<MatchingRules xmlns="http://soap.sforce.com/2006/04/metadata">
<matchingRules>
    <fullName>Custom_Contact_Rule1</fullName>
    <booleanFilter>((1 AND 2) OR 3 OR 4) AND 5</booleanFilter>
    <label>Custom Contact Rule1</label>
    <matchingRuleItems>
        <blankValueBehavior>NullNotAllowed</blankValueBehavior>
        <fieldName>FirstName</fieldName>
        <matchingMethod>FirstName</matchingMethod>
    </matchingRuleItems>
    <matchingRuleItems>
        <blankValueBehavior>NullNotAllowed</blankValueBehavior>
        <fieldName>LastName</fieldName>
        <matchingMethod>LastName</matchingMethod>
    </matchingRuleItems>
    <matchingRuleItems>
        <blankValueBehavior>NullNotAllowed</blankValueBehavior>
        <fieldName>Email</fieldName>
        <matchingMethod>Exact</matchingMethod>
    </matchingRuleItems>
    <matchingRuleItems>
        <blankValueBehavior>NullNotAllowed</blankValueBehavior>
        <fieldName>Phone</fieldName>
        <matchingMethod>Phone</matchingMethod>
    </matchingRuleItems>
    <matchingRuleItems>
        <blankValueBehavior>NullNotAllowed</blankValueBehavior>
        <fieldName>AccountId</fieldName>
        <matchingMethod>CompanyName</matchingMethod>
    </matchingRuleItems>
    <ruleStatus>Active</ruleStatus>
</matchingRules>


I would expect to be able to retrieve Duplicate Rule data as well, which specifies the following pieces of data

  • If sharing rules are enforced
  • If users can bypass the creation on create or edit
  • How the fields are mapped
5
  • Isn't matching rule is what used to identify the duplicates in an object? Or, are you looking for how to invoke one of these defined matching rules and get the duplicates? – singularity Feb 24 '15 at 17:15
  • You are correct - a MatchingRule defines logic to identify the duplicate in an object. I'm looking for DuplicateRule, which defines the logic to handle the duplicate once found. Very similar to WorkflowRule and an action on the WorkflowRule - like FieldUpdate. I will update my question to show the xml pulled from MatchingRules as well as what data I'm looking to pull as well. – zainogj Feb 24 '15 at 17:22
  • As of today, it seems to be unsupported. There is an idea for it on the IdeaExchange. – zainogj Feb 24 '15 at 19:07
  • Thanks. But be aware that changesets are different features than metadata api, even though both are for deployment. There are many components which are supported in Metadata api but not in changeset – singularity Feb 24 '15 at 19:14
  • Does anyone know if it's supported by DX deployments? Doesn't seem to be working for me. I can't retrieve Duplicate Rules, and I can retrieve but not deploy Matching Rules. Wanting to avoid converting my project to mdapi format just for deployment of these – Bow-chicawow-ers Jan 25 at 20:56
0

Migrating Duplicate Rules via Metadata API is officially supported starting with API version 42.0 (Spring '18). See the official documentation on how to use: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_duplicaterule.htm

4
  • Does anyone know if it's supported by DX deployments? Doesn't seem to be working for me. I can't retrieve Duplicate Rules, and I can retrieve but not deploy Matching Rules. Wanting to avoid converting my project to mdapi format just for deployment of these – Bow-chicawow-ers Jan 25 at 20:56
  • DuplicateRule Metadata Type is fully supported by SFDX Source Format. Also see mdcoverage.secure.force.com/docs/metadata-coverage/51, which states this officially. We are doing force:source:deploy a few dozen times a day... – ebi Jan 25 at 21:05
  • And you've personally seen Duplicate Rules retrieve & Matching Rules deploy successfully in these daily deployments? I've gotten Matching Rules to retrieve into a new matchingRules folder in the SFDX source folder via force:source:retrieve, but they aren't deploying (nor erroring upon deploy). Can't even get Duplicate Rules to retrieve – Bow-chicawow-ers Jan 26 at 0:57
  • Sure, both Metadata types are retrieved from and deploying into Scratch Orgs and Sandboxes regularly. I also just tested sfdx force:source:retrieve -m DuplicateRule,MatchingRules -u <org> as well as sfdx force:source:deploy -m DuplicateRule,MatchingRules -u <org> successfully. NOTE: The Metadata Types are named inconsistently (DuplicateRule = singular, MatchingRules = plural)! – ebi Jan 26 at 10:11
2

As mentioned on this idea, this is not included in the metadata and Salesforce is currently planning to add it to the roadmap. I'll update this answer once I hear that it's been released.

1
  • absence of this feature doesn't pass the straight-face test :-( – cropredy Jun 8 '16 at 0:28

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.