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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Whether Duplicate detection is enabled by default and how to disable without code

(0) ShareShare
ReportReport
Posted on by 10

Hi,

Whether Duplicate Detection settings is enabled by default and how to disable by code.

I have the same question (0)
  • Suggested answer
    Mohamed Sanuj Basheer Profile Picture
    540 on at

    Dear Partner,

    Duplicate Detection rule is enabled by default for few entities, please refer to the doc below

    https://docs.microsoft.com/en-us/powerapps/developer/data-platform/enable-disable-duplicate-detection

    you can achieve the same, using javascript. call this script in form onsave and enable ->pass Excution context as first parameter

    function GetData(executionObj)
    {
        debugger;
        var PracticeLocation = Xrm.Page.getAttribute("new_practicelocation").getValue();
        var EMRvendorProduct=Xrm.Page.getAttribute("new_emrvendorexist").getValue();

        if (PracticeLocation != null && EMRvendorProduct!=null )
        {

            var PracticeLocationId = PracticeLocation[0].id;

            var PracticeLocationName = PracticeLocation[0].name;

            var EMRvendorProductId = EMRvendorProduct[0].id;

            var EMRvendorProductName = EMRvendorProduct[0].name;

            var context = Xrm.Page.context;
            var serverUrl = context.getClientUrl();
            var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
            var retrieveResult = new XMLHttpRequest();
           
            retrieveResult.open("GET", ODataPath +"/new_emrrequestSet?$select=new_emrvendorexist,new_PracticeLocation&$filter=new_emrvendorexist/Id eq  guid'"+EMRvendorProductId+"' and new_PracticeLocation/Id eq guid'"+PracticeLocationId+"'",false);
            retrieveResult.setRequestHeader("Accept", "application/json");
            retrieveResult.setRequestHeader("Content-Type", "application/json; charset=utf-8?");
            retrieveResult.send();

            if (retrieveResult.readyState == 4 /* complete */)
            {
                if (retrieveResult.status == 200)
                {
                    var retrieved = this.parent.JSON.parse(retrieveResult.responseText).d;
                    var Result = retrieved.results;
                   
                    if (typeof Result !== "undefined")
                    {
                        
                        var count = Result.length;

                        if (count>1)
                        {
                            alert("duplicate value not allowed");
                            executionObj.getEventArgs().preventDefault();

                        }

                    }
                }

            }

        }
    }

    Ref:

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/208571/duplicate-detection-rule-prevent-the-record-from-saving

    Did I answer your question? Please consider to mark my post as a solution to help others.

     

    Regards,

    Mohamed Sanuj Basheer

  • EKL Profile Picture
    10 on at

    Thank you, I am looking to disable the below via code.

    pastedimage1610954394513v1.png

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 164 Super User 2026 Season 1

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 51 Most Valuable Professional

#3
NeerajPawar Profile Picture

NeerajPawar 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans