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)

MSCRM Update Rollup 14 - oData is not working.

(0) ShareShare
ReportReport
Posted on by 145

I am trying to make an Ajax call from MSCRM (My CRM Deployment is with Update Roll up 14 on OS SQL Server 2012). My function reaches in "I am Success" alert but than on next alert I receive error

--------------------------- Message from webpage ---------------------------

An error has occurred.

Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.

--------------------------- OK ---------------------------


Following is my code:

function retrieveSelectedRecord(accountId) {

var select = "&select=Name,accountId";

var filter = "&filter=AccountId eq guid'" + accountId + "'";

var oDataSelect;

oDataSelect = "/XRMServices/2011/OrganizationData.svc/AccountSet?" + select + filter;

jQuery.support.cors = true;

$.support.cors = true;

$.ajax({ type: "GET",

           contentType: "application/json;

           charset=utf-8", datatype: "json",

           url: oDataSelect, beforeSend:

           function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json");

},

success: function (data, textStatus, XmlHttpRequest)

{ // Use for a single selected entity

           alert("I am in Success");

           alert(data); ProcessReturnMsg(data.d); },

error: function (xmlHttpRequest, textStatus, errorThrown)

{

           alert("I am in Error");

           alert("Status: " + textStatus + "; ErrorThrown: " + errorThrown); }

});

}


function ProcessReturnMsg(entity) {

var name = entity.Name;

alert(name);

//Xrm.Page.getAttribute("uomid").setValue(defaultuomid);

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,562 on at

    I assume your error might have been coming when trying to display the record Name???

    The OData query you have is essentially could retrieve multiple records since you are using a filter condition (even though you are filtering by the unique id).

    So when processing the resulting data - you would need something like:

    var name = entity.results[0].Name;
    

    Also in your select, you should have "AccountId" -to match the correct schema name of the field.

    If you only want to select a single record by unique id, your OData query should look like:

    "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + accountId+ "')?$select=Name";
    

    Then you should not end up with the .results collection attached to the returned object.

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