RE: Throw an error in Dynamics 365
Hi Sumaira,
Sorry for my mistake, in your case we should use "retrievemultiplereocrds" to get data because "retrieveRecord" could only get an special record with GUID.
So just use "retrievemultiplereocrds" instead, and which entity are you filling the emailaddress? According to your code, I think you might using contact. Then you need to replace the main entity "email" with "contact".
function compareEmailID(executionContext){
var formContext = executionContext.getFormContext();
var emailID=formContext.getAttribute("emailaddress1").getValue();
Xrm.WebApi.retrieveMultipleRecords("contact","?$select=emailaddress1&$filter=emailaddress1 eq '" + emailID+"'").then(
function success(result) {
if (result.length>0) {
Xrm.Page.ui.setFormNotification("This EmailID is exsited, please try another one!", "ERROR")
}
},
function error(error) {
Xrm.Navigation.openAlertDialog({ text: error.message });
}
);
}
docs.microsoft.com/.../retrievemultiplerecords
Hope it helps.
Best Regards,
Leo