Enable duplicate lead detection for custom forms

The duplicate lead detection feature in Dynamics 365 Sales helps detect duplicate leads. By default, this feature is enabled for the main lead form in the Sales Hub app. However, if you've customized the main lead form, you must manually enable duplicate lead detection.

Note

This customization can be applied only to main forms of the Lead table in the custom app.

License and role requirements

Requirement type You must have
License Dynamics 365 Sales Enterprise, Dynamics 365 Sales Premium, or Microsoft Relationship Sales
More information: Dynamics 365 Sales pricing
Security roles System Administrator
More information: Predefined security roles for Sales

Add an OnLoad event handler to the custom form

Add an event handler to the OnLoad event of the main lead form to enable duplicate detection on the form.

  1. Sign in to the Power Apps portal.

  2. Search for and select your organization's environment.

  3. In the site map, select Tables, and then select the Lead table.

  4. In the Data experiences section, select Forms, and then select your custom lead form of the Main type.

  5. In the Main form pane that opens on the right, select the Events tab.

  6. In the On Load section, select + Event Handler.

  7. In the Configure Event dialog box, select + Add library.

  8. Add the DataHygiene/Data/salesdatahygiene_form_notification_library.js library, and then select it in the list.

  9. In the Function field, enter Mscrm.LeadHygiene.DataHygieneNotificationLibrary.duplicateDetectionFormOnLoad.

  10. Select the Pass execution context as first parameter checkbox.

  11. Select Done.

    Screenshot of the event configuration for the event handler for duplicate lead detection.

    In the Handlers section, notice that the required event handler has been added to the custom lead form.

  12. Save and publish the form.

    Duplicate lead detection is now enabled for the custom form. You must now enable the duplicate lead detection feature from the Sales Hub app. Learn how to enable duplicate lead detection.

Enable duplicate lead detection
Manage duplicate leads