Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

S- Dynamics CRM API Call Does not Return any result

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

  • Verified answer
    Suganthar_Satkunam Profile Picture
    Suganthar_Satkunam 210 on at
    RE: S- Dynamics CRM API Call Does not Return any result

    Thanks Mate. That solved my Issue

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: S- Dynamics CRM API Call Does not Return any result

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans