Filtering Records with FetchXML
Every configuration record can carry an optional custom FetchXML statement that determines which records the analysis examines.
Leave it blank and all active records of the entity are analyzed. That's the right default for most first runs.
When to filter
| Situation | Why filter |
|---|---|
| First run on a large CRM | Analyze a slice, validate the rules, then widen |
| Duplicates concentrated in one segment | Skip records you know are clean |
| Different rules per segment | B2C contacts and B2B contacts may need different matching |
| Testing rule changes | Keep the feedback loop short |
How to build one
Don't write FetchXML by hand. Generate it:
- Open Advanced Find in your CRM.
- Add the filters you want.
- Use Download Fetch XML.
- Paste the result into the Custom FetchXML field on the configuration record.
Example
All contacts whose parent account is in the Consumer Services industry:
<fetch>
<entity name="contact">
<attribute name="fullname" />
<link-entity name="account" from="accountid" to="parentcustomerid">
<filter>
<condition attribute="industrycode" operator="eq" value="37" />
</filter>
</link-entity>
</entity>
</fetch>
Submit a request against that configuration and only those contacts are analyzed.
Security roles filter too
The FetchXML statement is only the first filter. The CRM user configured in the CRM connection is also bound by its security roles, which can further restrict what the analysis sees.
If an analysis returns fewer records than you expect and the FetchXML looks right, check the connection user's roles. See the Azure app user page for what the AutoMerge Non-Admin User role does and doesn't grant.
Practical advice
- Widen gradually. Start narrow, confirm the precision distribution looks sane on the dashboard, then remove filters.
- Keep a Sandbox configuration. Same rules, filtered to a small set, pointed at a Sandbox connection. A cheap way to test rule changes.
- Match the filter to the rules. If a configuration's matching rules assume B2B data, its FetchXML should select B2B records.