Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Alert on Duplicate record and allow to save

(0) ShareShare
ReportReport
Posted on by 310

Hello ,

How can I  give an alert message and Allow to Save the record after duplicate detection of record or fields using only plugin or Javascript ?

I already have a plugin for duplicate detection but it not allow to save after duplicate detection

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 Moderator on at
    RE: Alert on Duplicate record and allow to save

    Hi Manoj ,

    You can not show warning message using plugin , you can only shows Business error/message, which basically stops executing plugin, in other words restrict save only. So you have to go with the way which Rawish suggested above .

    For more information about CRMSDKRestBuilder  and prepare code please have a look below video -

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Alert on Duplicate record and allow to save

    Okay.

    All you have  to do is get values from the current record and do web api query to see if you find any other record with those values if yes then display an alert.

    use rest builder to build the request : https://github.com/jlattimer/CRMRESTBuilder/releases  

    In below example i am searching for other contact record using email address and phone number and if count is greater then 0 i m showing an alert. 

    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/contacts?$filter=address1_telephone1 eq '5656565655' and emailaddress1 eq 'rawkum%40ms.com'&$count=true", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 200) {
    var results = JSON.parse(this.response);
    var recordCount = results["@odata.count"];
    if recordCount>0
    Xrm.Utility.alertDialog("Duplicate Record Exist");
    }
    } else {
    Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send();

  • Screen one Profile Picture
    Screen one 310 on at
    RE: Alert on Duplicate record and allow to save

    My client wants only by coding ...

    how to check duplicates using js

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Alert on Duplicate record and allow to save

    Hi Manoj,

    Out of the box duplicate detection rule gives you an alert/popup and allows to save the record. You could utilize that very well.

    Apart from it if you need to use javascript , you could create a function which you can call on Onsave event of create form and put alert.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans