web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

S- Dynamics CRM API Call Does not Return any result

(0) ShareShare
ReportReport
Posted on by 210

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

05218.1.PNG

Actually I have tested the service call, There is a data exists for that

3276.2.PNG

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

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi,

    Your issue is most likely in this line:

    retrieveResult.open("GET", ODataPath +"/LeadSet?$select=FullName&$filter=(Telephone1 eq '+mobilevalue+')",false);

    Notice that you are using different types of quotes. Should be:

    retrieveResult.open("GET", ODataPath +"/LeadSet?$select=FullName&$filter=(Telephone1 eq '" + mobilevalue +"')",false);

    Hope this helps.

  • Verified answer
    Suganthar_Satkunam Profile Picture
    210 on at

    Thanks Mate. That solved my Issue

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans