Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

List only the duplicate leads in a view

Posted on by 1,075

Hello Community Experts,

Is there any way where i can list all the duplicate records of a lead in a separate view?

I found OOB it is not possible, is it possible via code?

Please advise

Best Regards,

Sumaira Noor

  • Sumaira Noor Profile Picture
    Sumaira Noor 1,075 on at
    RE: List only the duplicate leads in a view

    Thanks a lot for the response Nathan and Mehdi

    Thank you for taking time to help me Mehdi. I tried the code and it shows the duplicates under subgrid.

    Many thanks for it. I learned something new.

    I will suggest this solution to my client. Hope she agrees for this.

    Best Regards,

    Sumaira Noor

  • Verified answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: List only the duplicate leads in a view

    Hi, 

    I replay your scenario using some unsupported code. 

    First, you need to add a subgrid to you form. I used Lead Entity as an example. I added the subgrid within a section wish is hidden by default. 

     duplicates.png

    Then you can add this JS function in onLoad event. This function inject dynamically a fetchXml to the subgrid. Basically, I retrieve leads with the same Topic, FirstName and LastName. 

    function getDuplicates(executionContext) {
    
        var formContext = executionContext.getFormContext();
        if (formContext.ui.getFormType() != 1) {
            var duplicatesGridControl = formContext.getControl("Duplicates");
    
            if (duplicatesGridControl == null) {
                setTimeout(getDuplicates, 2000);
            }
            else {
                var leadId = formContext.data.entity.getId().replace("{", "").replace("}", "");
                var firstName = formContext.getAttribute('firstname').getValue();
                var lastName = formContext.getAttribute('lastname').getValue();
                var topic = formContext.getAttribute('subject').getValue();
    
                var fetchData = {
                    subject: topic,
                    firstname: firstName,
                    lastname: lastName,
                    leadid: leadId
                };
                var fetchXml = [
                    "",
                    "  ",
                    "    ",
                    "      ",
                    "      ",
                    "      ",
                    "      ",
                    "    ",
                    "  ",
                    "",
                ].join("");
    
                
                duplicatesGridControl.setFilterXml(fetchXml);
                duplicatesGridControl.refresh();
                var summaryObj = formContext.ui.tabs.get("Summary");
                var duplicatesObj = summaryObj.sections.get("Summary_Duplicates");
                duplicatesObj.setVisible(true);
            }
        }
    
    
    }
    
    

    Hope this helps, good luck :) 

  • Suggested answer
    sdfasdf Profile Picture
    sdfasdf 840 on at
    RE: List only the duplicate leads in a view

    Hi Sumaira,

    I'm afraid you won't be able to create a view to list the duplicate records, however you can review the duplicate records by running a Duplicate Detection Job -- https://docs.microsoft.com/en-us/power-platform/admin/run-bulk-system-jobs-detect-duplicate-records -- which will take into account the Duplicate Detection Rules you have in place.

    You can always use SDK to retrieve the duplicate records as well, but that would involve more development effort than just running the Duplicate Detection Job.

    I hope it helps.

    Thanks,

  • meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: List only the duplicate leads in a view

    Hi Sumarai please avoid to duplicate your threads.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans