Hi guys,
I'm trying to find a way to suppress the duplicate detection using javascript, is this possible at all?
The reason for this is because i'm creating an account using javascript and sometimes when the user clicks save on the duplicate detection rule the account does not get created because the detection rule fires before the account is created and it stops the function. Sample code is bellow, any suggestions or ideas are welcomed.
Code sample:
//create new account entity var createAccount = new XrmServiceToolkit.Soap.BusinessEntity("account"); //validate name if (Xrm.Page.getAttribute("firstname").getValue() == null) { alert("Name of potential supplier is missing, please provide it before continuing"); return; } else { createAccount.attributes["name"] = Xrm.Page.getAttribute("firstname").getValue(); } //validate primary contact if (Xrm.Page.getAttribute("parentcontactid").getValue() == null) { alert("Please select a primary contact first"); return; } else { createAccount.attributes["primarycontactid"] = { id: Xrm.Page.getAttribute("parentcontactid").getValue()[0].id, logicalName: "contact", type: "EntityReference" }; } createAccount.attributes["address1_country"] = Xrm.Page.getAttribute("address1_composite").getValue(); createAccount.attributes["websiteurl"] = Xrm.Page.getAttribute("websiteurl").getValue(); createAccount.attributes["originatingleadid"] = { id: Xrm.Page.data.entity.getId(), logicalName: "lead", type: "EntityReference" }; // check if lead has already been qualified if (Xrm.Page.getAttribute("statuscode").getValue() == 3 && Xrm.Page.getAttribute("statecode").getValue() == 1) { alert("This lead has already been qualified"); return; } // qualify lead Xrm.Page.getAttribute("statuscode").setValue(3); Xrm.Page.getAttribute("statecode").setValue(1); Xrm.Page.data.save().then(function OnSuccess() { var accountId = XrmServiceToolkit.Soap.Create(createAccount); //Open newly created account record Xrm.Utility.openEntityForm("account", accountId); }, function ErrorCallback(e) { alert(e.message); console.log("error"); })
*This post is locked for comments