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.
Sign in to the Power Apps portal.
Search for and select your organization's environment.
In the site map, select Tables, and then select the
Lead
table.In the Data experiences section, select Forms, and then select your custom lead form of the Main type.
In the Main form pane that opens on the right, select the Events tab.
In the On Load section, select + Event Handler.
In the Configure Event dialog box, select + Add library.
Add the
DataHygiene/Data/salesdatahygiene_form_notification_library.js
library, and then select it in the list.In the Function field, enter Mscrm.LeadHygiene.DataHygieneNotificationLibrary.duplicateDetectionFormOnLoad.
Select the Pass execution context as first parameter checkbox.
Select Done.
In the Handlers section, notice that the required event handler has been added to the custom lead form.
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.