Hi Guys,
I write Javascript for Form level notification, once the condition is match the error notification is come to form level.if the condition is doesn't match means i want to clear the form level notification. i write clear notification methods but it doesn't working.i don't know where i want to write the clear notification method.
this is my code. I need to know where i want to write clear notification line. I don't know where i made mistake
function cBlack() {
var vsEmail = Xrm.Page.getAttribute("new_email").getValue();
var vsMobilePhone = Xrm.Page.getAttribute("new_mobilephone").getValue();
if (vsEmail != null && vsMobilePhone != null) {
var rs_Email = vsEmail.toLowerCase().trim();
var rs_MobilePhone = vsMobilePhone.replace(/ +/g, "");
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/new_black?$select=emailaddress,new_mobilenumber", 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);
for (var i = 0; i < results.value.length; i++) {
var internalemailaddress = results.value[i]["emailaddress"];
var resultEmail = internalemailaddress.toLowerCase().trim();
var mobileNumber = results.value[i]["new_mobilenumber"];
var resultMobile = mobileNumber.replace(/ +/g, "");
if (rs_Email == resultEmail && rs_MobilePhone == resultMobile) {
Xrm.Page.ui.setFormNotification("This record is in blacklist ", "ERROR", "100");
//Xrm.Utility.alertDialog("This record is in blacklist")
}
else
{
rm.Page.ui.clearFormNotification("100");
}
}
}
else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}
else {
return true;
}
}
Please help me Guys..
Thank You
*This post is locked for comments