web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    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.

  • Screen one Profile Picture
    310 on at

    My client wants only by coding ...

    how to check duplicates using js

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    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();

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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 -

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans