Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Javascript ODATA Not working

Posted on by Microsoft Employee

I am executing user saved query using OData in javascript to retrieve usersavedquery GUID but i am facing error "executeUserQuery is not defined"

Kindly suggest what is the issue code.

function executeUserQuery() {
debugger;
var clientUrl = Xrm.Page.context.getClientUrl();
var req = new XMLHttpRequest();
req.open("GET", encodeURI(clientUrl + "/api/data/v8.0/userqueries?$select=name,userqueryid&$filter=name eq 'Fourth Coffee Won Opportunities'", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null;
if (this.status == 200) {
var data = JSON.parse(this.response);
var dat = data.value;
alert(dat);
}
else {
var error = JSON.parse(this.response).error;
alert(error.message);
}
}
};
req.send();
}

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Javascript ODATA Not working

    7446.error1.PNG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Javascript ODATA Not working

    Yes, I have added javascript on the form.

    0511.error.png

  • Suggested answer
    M.T. Eikelenboom Profile Picture
    M.T. Eikelenboom 5,241 on at
    RE: Javascript ODATA Not working

    That error says that your function you posted above is not available.

    Did you add the javascript file to the form?

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans