Duplicate Detection within Dynamics 365 using PowerApps

Scenario: While creating a contact in Dynamics 365, check whether a contact of the same email address already exists or not, If exists then display a duplicate email address error message.

Step 1. Screen 1 - Create a Blank Canvas App > Connect with Dynamics 365 Data Source > Connect Contact Entity as Dataset (You can connect other entities also as per your requirement).

Canvas app

Duplicate detection

Step 2. Screen 2 - Insert a new Blank Screen to show Duplicate Detection Dialog.

Blank Screen

Step 3. Add a few Text Inputs and Button Controls in Screen 1 or design as per your need.

Text Inputs

Step 4.  Add the below formula on Button Control (onSelect property) to find a Duplicate Record.

If(
    IsBlank(
        LookUp(
            Contacts,
            emailaddress1 = Emailaddress_Text.Text
        )
    ),
    UpdateContext({result: "Duplicates Record not found"}),
    Navigate(DuplicateDetectionDailogbox, ScreenTransition.CoverRight)
);

ScreenTransition

You can use the following formula also on Button Control (onSelect property) to find a Duplicate Record.

UpdateContext({recordCount: CountIf(Contacts, emailaddress1 = Emailaddress_Text.Text)});

If(
    recordCount > 0,
    Navigate(DuplicateDetectionDailogbox, ScreenTransition.Fade)
)

Step 5. Test the App.

Before running the App, I’ve taken the existing email address from an existing contact.

 Existing contact

And I’ve entered the details into the App. Upon clicking 'Submit,' the Duplicate Detection Screen will appear.

Duplicate Detection Screen

If you provide a new email address that does not exist in the contact records, the result will be displayed as “Duplicates Record not found”. You can find results from variables.

Variables


Similar Articles