MatchingRule

Represents a matching rule that is used to identify duplicate records.

Parent Type 

This type extends Metadata and inherits its fields.

File Suffix and Directory Location 

Matching rule components have the .matchingRule suffix and are stored in the matchingRules folder. The name of the component file is the standard or custom object name that is associated with the matching rule.

In API version 39.0 and later, MatchingRule supports the Person Account object.

  • The component file name is PersonAccount.matchingRule.
  • The component directory is matchingRules.

Version 

Introduced in API version 33.0.

Fields 

booleanFilter 

  • Type: string
  • Required: No
  • Description: Specifies filter logic conditions.

description 

  • Type: string
  • Required: No
  • Description: The description of the matching rule.

label 

  • Type: string
  • Required: Yes
  • Description: Required. The name of the matching rule.

matchingRuleItems 

  • Type: MatchingRuleItem[]
  • Required: No
  • Description: The criteria that make up a matching rule.

ruleStatus 

  • Type: MatchingRuleStatus (enumeration of type string)

  • Required: Yes

  • Description: Required. The activation status of the matching rule. Values are:

    • Inactive
    • Deactivating
    • DeactivationFailed
    • Active
    • Activating
    • ActivationFailed

The only valid values you can declare when deploying a package are Active and Inactive .

Important

MatchingRuleItem Type 

Fields 

blankValueBehavior 

  • Type: BlankValueBehavior (enumeration of type string)

  • Required: No

  • Description: Specifies how blank fields affect whether the fields being compared are considered matches. Valid values are:

    • MatchBlanks
    • NullNotAllowed (default)

fieldName 

  • Type: string
  • Required: Yes
  • Description: Required. Indicates which field to compare when determining if a record is similar enough to an existing record to be considered a match.

matchingMethod 

  • Type: MatchingMethod (enumeration of type string)

  • Required: Yes

  • Description: Required. Defines how the fields are compared. Choose between the exact matching method and various fuzzy matching methods. Valid values are:

    • Exact
    • FirstName
    • LastName
    • CompanyName
    • Phone
    • City
    • Street
    • Zip
    • Title

    For details on each matching method, see “Matching Methods Used with Matching Rules” in the Salesforce Help.

Declarative Metadata Sample Definition 

The following is a sample XML definition of a matching rule. A matching rule can be associated with either a standard or a custom object.

1<?xml version="1.0" encoding="UTF-8"?>
2<MatchingRules xmlns="http://soap.sforce.com/2006/04/metadata">
3<matchingRules>
4<fullName>AccountMatchingRule</fullName>
5<label>Matching rule for accounts</label>
6<description>this is sample rule description</description>
7<matchingRuleItems>
8<blankValueBehavior>NullNotAllowed</blankValueBehavior>
9<fieldName>BillingCity</fieldName>
10<matchingMethod>City</matchingMethod>
11</matchingRuleItems>
12
13<matchingRuleItems>
14<blankValueBehavior>NullNotAllowed</blankValueBehavior>
15<fieldName>Name</fieldName>
16<matchingMethod>CompanyName</matchingMethod>
17</matchingRuleItems>
18
19<ruleStatus>Inactive</ruleStatus>
20</matchingRules>
21</MatchingRules>

The following package.xml shows how to reference a matching rule by name. It specifies the type name of MatchingRule.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3<types>
4<members>Account.AccountMatchingRule</members>
5<name>MatchingRule</name>
6</types>
7<version>68.0</version>
8</Package>

The following package.xml shows how to reference all matching rules by specifying the plural MatchingRules type name and using a wildcard to include all members.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3<types>
4<members>*</members>
5<name>MatchingRules</name>
6</types>
7<version>68.0</version>
8</Package>

Wildcard Support in the Manifest File 

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.