Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Querying CRM Data using ODATA End Point

(0) ShareShare
ReportReport
Posted on by 379

Hi, 

I am trying to retrieve the list of activities associated with a contact, and then display a warning message if any of the activities are open and assigned to a current logged-in user. But i am getting an error . its showing problem with URL but it was working last week and suddenly its not. Any help will be greatful

HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).

(XHR)GET - https://******.crm.dynamics.com/_static/_common/scripts/es6-shim.map

Here is my java script code

function checkActiveTasksAssignedToMe()
{
var uniqueNotificationId = "OutstandingTasks";

Xrm.Page.ui.clearFormNotification(uniqueNotificationId);

var contactId = Xrm.Page.data.entity.getId().replace(/[{}]/g,"");
var currentUserId = Xrm.Page.context.getUserId().replace(/[{}]/g,"");

var req = new XMLHttpRequest();
var requestUrl = Xrm.Page.context.getClientUrl() + "/api/data/v8.2/tasks?$filter=_regardingobjectid_value eq " + contactId + " and _ownerid_value eq " + currentUserId + " and statecode eq 0";

req.open("GET", requestUrl, true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=\"OData.Community.Display.V1.FormattedValue\"");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);

if(results.value.length > 0){
Xrm.Page.ui.setFormNotification("You have outstanding tasks assigned to you.", "WARNING", uniqueNotificationId)
}
}
else {
//.. handle error
}
}
};
req.send();
}

*This post is locked for comments

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Querying CRM Data using ODATA End Point

    CRM App is cross-browser so it should work fine in any browser.

  • ZeroHar Profile Picture
    ZeroHar 379 on at
    RE: Querying CRM Data using ODATA End Point

    Hi,

    Thanks for the help. Code is working fine in IE browser, but having problems in Chrome. Can you please explain me, what browser is good for accessing CRM..

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Querying CRM Data using ODATA End Point

    Hello,

    Your code looks good for me. Can you add an alert after var requestUrl =  ... code to check if url was built properly?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans