Duplicate Rule entities

For information about how to configure duplicate rules in the application, see Administrators Guide: Set up duplicate detection rules to keep your data clean.

Duplicate detection rules are defined using the following entities:

These entities are related using the DuplicateRule_DuplicateRuleConditions relationship.

The following writable attributes in these entities control the behavior of duplicate detection rules.

DuplicateRule

Attribute Description
BaseEntityName Record type of the record being evaluated for potential duplicates.
Description Description of the duplicate detection rule.
DuplicateRuleId Unique identifier of the duplicate detection rule.
ExcludeInactiveRecords Determines whether to flag inactive records as duplicates.
Note:
The default value is false. Set it to true if you do not want inactive records to be flagged as duplicates, even if they meet duplication detection rule criteria.
More information: Inactive states
IsCaseSensitive Indicates if the operator is case-sensitive.
MatchingEntityName Record type of the records being evaluated as potential duplicates.
Name Name of the duplicate detection rule.
OwnerId Unique identifier of the user or team who owns the duplicate detection rule.
OwnerIdType Whether the owner is a user or a team.
StatusCode Reason for the status of the duplicate detection rule.

Inactive states

Most system entities and all custom entities have two StateCode attribute options:

  • Value: 0 InvariantName: Active
  • Value: 1 InvariantName: Inactive

The label of the option may be changed, but the InvariantName value will not.

Some system entities will have more than one active or inactive state.The following table lists examples of entities with more than one active or inactive state.

Entity StateCode Active State(s) Inactive State(s)
Appointment.StateCode Open, Scheduled Completed, Canceled
CampaignActivity.StateCode Open Closed, Canceled
CampaignResponse.StateCode Open Completed, Canceled
Contract.StateCode Draft, Invoiced, On Hold Canceled, Expired
ContractDetail.StateCode Existing, Renewed Canceled, Expired
Email.StateCode Open Completed, Canceled
Fax.StateCode Open Completed, Canceled
Incident.StateCode Active Resolved, Canceled, Closed
Invoice.StateCode Active Closed, Paid, Canceled
KbArticle.StateCode Draft, Unapproved, Published N/A
Lead.StateCode Open Qualified, Disqualified
Letter.StateCode Open Completed, Canceled
Opportunity.StateCode Open Won, Lost
PhoneCall.StateCode Open Completed, Canceled
Quote.StateCode Draft, Active Won, Closed
SalesOrder.StateCode Active, Submitted, Invoiced Canceled, Fulfilled
ServiceAppointment.StateCode Open, Scheduled Closed, Canceled
Task.StateCode Open Completed, Canceled

For example, if you set the ExcludeInactiveRecords attribute to true, only Active, Submitted, and Invoiced sales orders will be considered for matching during duplicate detection.

Note

You can review the available StateCode options for an entity using the Metadata Browser described in Browse the metadata for your organization.

To retrieve the StateCode options for an entity you can use the following Web API query by substituting the LogicalName of the entity with appointment used below:

GET [organization URI]/api/data/v9.1/EntityDefinitions(LogicalName='appointment')/Attributes(LogicalName='statecode')/Microsoft.Dynamics.CRM.StateAttributeMetadata/OptionSet?$select=Options

DuplicateRule Special messages

DuplicateRule is a user-owned entity and normal create, retrieve, update, assign, and delete operations are allowed as well as operations to control access. More information: DuplicateRule Messages.

The following special messages can also be used:

Message Web API Operation SDK Assembly
CompoundUpdateDuplicateDetectionRule CompoundUpdateDuplicateDetectionRule Action CompoundUpdateDuplicateDetectionRuleRequest
PublishDuplicateRule PublishDuplicateRule Action PublishDuplicateRuleRequest
PublishXml PublishXml Action PublishXmlRequest
UnpublishDuplicateRule UnpublishDuplicateRule Action UnpublishDuplicateRuleRequest

DuplicateRuleCondition

Attribute Description
BaseAttributeName Field that is being compared.
DuplicateRuleConditionId Unique identifier of the condition.
IgnoreBlankValues Determines whether to consider blank values as non-duplicate values.
Note:
The default value of this attribute is false. Set it to true if you do not want the duplicate detection rule to consider null values as equal.
Important:
For a duplicate detection rule with one condition, if you set the attribute value to false, it is treated by the system as a true value.
MatchingAttributeName Field that is being compared with the base field.
OperatorCode Operator for this rule condition.
Important:
If you set the OperatorCode attribute to ExactMatch, don’t set the OperatorParam attribute to any value
OperatorParam Parameter value of N if the operator is Same First Characters or Same Last Characters.
Important:
Don’t set the OperatorParam to zero during create or update operations.
RegardingObjectId Unique identifier of the object with which the condition is associated.

DuplicateRuleCondition Special messages

DuplicateRuleCondition is a child entity to DuplicateRule. Access to retrieve or modify these entities is dependant on access to the DuplicateRule it is associated with. More information: DuplicateRuleCondition Messages.

The following special messages can also be used:

Message Web API Operation SDK Assembly
CompoundUpdateDuplicateDetectionRule CompoundUpdateDuplicateDetectionRule Action CompoundUpdateDuplicateDetectionRuleRequest

See also

duplicaterule EntityType
duplicaterulecondition EntityType
Detect duplicate data
Enable and disable duplicate detection
Run duplicate detection
Duplicate detection messages
Sample: Enable duplicate detection and retrieve duplicates
Sample: Use duplicate detection when creating and updating records
Sample: Detect multiple duplicate records