MatchingRules is the object-scoped container for matching rules that identify duplicate records. Its matchingRules array contains individual MatchingRule definitions. Each child has its own comparison criteria, filter logic, identity, and activation status; these are not container-wide settings.
Do not confuse the container with an individual MatchingRule or with DuplicateRule. Matching rules define how records are compared. Duplicate rules are separate metadata that controls what happens when duplicates are found.
Key Elements
Except for the container's matchingRules array, the elements below belong to an individual child rule or one of its comparison items.
| Element | What the Element Controls |
|---|---|
matchingRules |
The array of individual matching-rule definitions within the object-scoped container. |
fullName |
The child's API identity within the container. For manifest member Account.AccountMatchingRule, the child's value is AccountMatchingRule, not the object-qualified member name. |
label |
Required. The displayed name of the child rule, separate from its fullName. |
booleanFilter |
The logical combination of the comparisons in matchingRuleItems. Read it together with those items rather than treating the field list alone as the matching logic. |
matchingRuleItems |
The array of field-comparison criteria for the child rule. Each item selects a field, a comparison method, and blank-value behavior. |
fieldName |
Required on each comparison item. Identifies the field to compare and can reference a CustomField component. |
matchingMethod |
Required on each comparison item. Allowed values are Exact, FirstName, LastName, CompanyName, Phone, City, Street, Zip, and Title. |
blankValueBehavior |
Controls how blank fields affect matching. Allowed values are MatchBlanks and NullNotAllowed. The default is NullNotAllowed. |
ruleStatus |
Required on each child. Records its activation state. Only Active and Inactive are valid declarations in a deployment package. |
Behavior and Constraints
The field list is only part of the matching logic. The same fields can produce different matching results when booleanFilter, matchingMethod, or blankValueBehavior changes.
Exact is distinct from the specialized fuzzy methods. Fuzzy matching compares similarity rather than requiring literal equality. A field's presence in a rule therefore does not mean its values must be identical for records to match.
blankValueBehavior concerns comparison behavior, not record storage. In particular, NullNotAllowed does not make the underlying field required when saving a record.
In addition to Active and Inactive, the recognized child status values are Activating, Deactivating, ActivationFailed, and DeactivationFailed. These four values are not valid deployment declarations.
Existing child rules can encounter activation-related update restrictions. The destination child's state matters: declaring the same ruleStatus in the existing and proposed metadata does not, by itself, rule out a status-related deployment error.
Deployment and Retrieval
Metadata API component files use the .matchingRule suffix and reside in the matchingRules folder. The file name identifies the associated standard or custom object, not an individual child rule. For example, Account rules belong in matchingRules/Account.matchingRule. Person Account matching rules use matchingRules/PersonAccount.matchingRule.
Keep these identities separate when building a package.xml manifest, the file that selects metadata components for deployment or retrieval:
-
Container and outer XML element:
MatchingRules. -
All matching rules: use manifest type
MatchingRuleswith member*. -
One child rule: use manifest type
MatchingRulewith member<objectName>.<ruleFullName>, such asAccount.AccountMatchingRule. -
Identity inside the container: the corresponding child's
fullNameisAccountMatchingRule, notAccountorAccount.AccountMatchingRule.
The entire component file base, meaning the file name without its directory and metadata extension, supplies the object name. Preserve any namespace in that name.
For a failing update, distinguish the destination child's activation state from the status declared in the proposed metadata. Reports include failures after changing criteria while leaving the declared status unchanged, as well as failures when a related DuplicateRule was deployed alongside the matching-rule update.
The reported replacement workarounds below delete individual MatchingRule components, not the object-level container. They do not establish a general requirement to delete rules for every update, or a universal deployment order for matching and duplicate rules.
Relationships
The container groups individual MatchingRule definitions for one object. Within each child, the compared field creates a separate element reference. A field reference alone does not establish that the child is active or used at runtime.
References
-
CustomField:fieldNameon a child'smatchingRuleItems.
Name-based association: CustomObject is associated through the entire container file base using the pattern <objectName>. This is not an XML element reference and can identify a standard or custom object. Preserve namespaces and the full object name. The association alone does not prove that an associated component exists in a particular org, require the components to be deployed together, or establish deletion order.
Changes to a field named by fieldName can affect the rule's comparison criteria. Related DuplicateRule components also matter when diagnosing replacement failures, but they remain separate assets from the matching-rule container and its children.
Reported Issues
-
An update can fail even when both definitions declare
Active. In May 2024, an author reported "Change the matching rule status separately from other changes" after adding amatchingRuleItemsentry and changingbooleanFilter. Both the existing and proposed definitions declaredActive. The author reported resolving the failure by deleting and redeploying the individualMatchingRule. This was a replacement workaround, not evidence that every criteria update requires deletion. See the unchanged-status update report. -
A matching-rule update can fail alongside a separate duplicate-rule error. In August 2024, an author reported "Before you change a matching rule, you must deactivate it" and an unexpected
DuplicateRuleerror in the same deployment. The author reported deleting theDuplicateRulefirst, then the individualMatchingRule, before redeploying. The report does not establish the cause of the unexpected duplicate-rule error or a mandatory order for ordinary deployments. See the matching and duplicate rule replacement report. -
Deleting the object-level container can fail instead of removing its children. An org-cleanup answer updated in 2022 records "Matching Rules have to be deleted individually" for an attempted
MatchingRulesdeletion ofAccount.matchingRule. Its cleanup script excludes the container type and handles individualMatchingRulecomponents separately; it also excludes standard matching rules from its deletion selection. See the bulk metadata cleanup discussion.
Common Questions
What is the difference between MatchingRules and MatchingRule in package.xml?
MatchingRules identifies the object-scoped container and supports * to request all matching rules. MatchingRule addresses an individual child using an object-qualified member such as Account.AccountMatchingRule.
Why does a matching-rule deployment fail when ruleStatus has not changed?
An unchanged declaration does not rule out activation-related restrictions in the destination org. A May 2024 report encountered a status-change error after changing comparison criteria while both definitions declared Active. Deleting and redeploying the child was the reported workaround, not a general update requirement.
Can I deploy a matching rule with ruleStatus set to Activating?
No. Only Active and Inactive are valid deployment declarations. Activating, Deactivating, ActivationFailed, and DeactivationFailed are recognized states but cannot be declared in a deployment package.
Does NullNotAllowed make the compared field required?
No. NullNotAllowed controls how blank values affect matching. It does not make the field required when storing a record.
What file contains Person Account matching rules?
Person Account matching rules use matchingRules/PersonAccount.matchingRule. The file is an object-scoped container; each child inside it has its own fullName, criteria, and activation status.