Newer Version Available

This content describes an older version of this product. View Latest

MatchingRule

Represents a matching rule that is used to identify duplicate records. This type extends the Metadata metadata type and inherits its fullName field.

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.

Version

MatchingRule is available in API version 33.0 and later.

Fields

Field Name Field Type Description
booleanFilter string Specifies filter logic conditions. For more information on filter logic, see “Getting the Most Out of Filter Logic” in the Salesforce Help.
description string The description of the matching rule.
label string Required. The name of the matching rule.
matchingRuleItems MatchingRuleItem The criteria that make up a matching rule.
ruleStatus MatchingRuleStatus (enumeration of type string) Required. The activation status of a 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

Field Name Field Type Description
blankValueBehavior BlankValueBehavior (enumeration of type string) Specifies how blank fields affect whether the fields being compared are considered matches. Valid values are:
  • MatchBlanks
  • NullNotAllowed (default)
fieldName string Required. Indicates which field to compare when determining if a record is similar enough to an existing record to be considered a match.
matchingMethod MatchingMethod (enumeration of type string) 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>33.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>33.0</version>
8</Package>