Hi,
Whether Duplicate Detection settings is enabled by default and how to disable by code.
Hi,
Whether Duplicate Detection settings is enabled by default and how to disable by code.
Thank you, I am looking to disable the below via code.
Dear Partner,
Duplicate Detection rule is enabled by default for few entities, please refer to the doc below
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:
Did I answer your question? Please consider to mark my post as a solution to help others.
Regards,
Mohamed Sanuj Basheer
André Arnaud de Cal... 291,559 Super User 2024 Season 2
Martin Dráb 230,579 Most Valuable Professional
nmaenpaa 101,156