Hi Team,
In WS call from CRM and checked the response using the Internet Explorer 'F12' Tool. I got the repose code as 200 (OK) but I have not got any result set. See the screenshot below
Actually I have tested the service call, There is a data exists for that
My Updated the JS script fucntion is as below
function CaptureRequirements_onSave(eventArgs) {
var mobile = Xrm.Page.getAttribute("mobilephone");
var email = Xrm.Page.getAttribute("emailaddress1");
var mainPhone = Xrm.Page.getAttribute("telephone1");
var isNull = mobile.getValue() == null && email.getValue() == null && mainPhone.getValue() == null;
var isBlank = mainPhone.getValue() == "" && mobile.getValue() == "" && email.getValue() == "";
var notificationMessage = "Error";
if (isNull || isBlank) {
Xrm.Page.ui.setFormNotification("To save this record, please enter either an Email address, Main Phone or Mobile number.", "ERROR", notificationMessage);
eventArgs.preventDefault();
eventArgs.returnValue = false;
}
else {
Xrm.Page.ui.clearFormNotification(notificationMessage);
}
if (mainPhone.getValue() != null || mobile.getValue() != null)
{
var mainphonevalue= mainPhone.getValue();
var mobilevalue=mobile.getValue();
var context = Xrm.Page.context;
var serverUrl = context.getClientUrl();
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
var retrieveResult = new XMLHttpRequest();
alert(mobilevalue);
debugger;
retrieveResult.open("GET", ODataPath +"/LeadSet?$select=FullName&$filter=(Telephone1 eq '+mobilevalue+')",false);
retrieveResult.setRequestHeader("Accept", "application/json");
retrieveResult.setRequestHeader("Content-Type", "application/json; charset=utf-8?");
retrieveResult.send();
debugger;
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")
{
for (var i = 0; i < Result.length; i++) {
alert(Result[i].FullName);
}
var count = Result.length;
if (count>1)
{
alert("duplicate value not allowed");
executionObj.getEventArgs().preventDefault();
}
}
}
}
/*Xrm.Page.ui.setFormNotification(ODataPath, "ERROR", notificationMessage);
eventArgs.preventDefault();
eventArgs.returnValue = false;*/
}
}
I really do not know why i do not get any result set when i was checking through the debugging mode? Can you please shed some light ? or please let me know what other steps to dig the cause of the issue in Dynamics CRM.
*This post is locked for comments