Sample Code: OData Synchronous Call in CRM 2011

Just sharing the sample code to make synchronous OData call in CRM 2011.


var oDataRequestUrl = http://server/orgname/xrmservices/2011/OrganizationData.svc/ContactSet?$select=FullName

var result = syncODataCall(oDataRequestUrl);

// function to make synchronous oData call
 function syncODataCall(odataSelect) {
 var request = new XMLHttpRequest();
 request.open("GET", odataSelect, false);
 request.setRequestHeader("Accept", "application/json");
 request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
 request.send();
 var objJQuery = jQuery.parseJSON(request.responseText);
 return objJQuery.d
 }

Check for following methods to parse the result returned

  • ProcessReturnedEntities(data.d.results)
  • ProcessReturnedEntity(data.d)

http://crmscape.blogspot.in/2011/03/crm-2011-odata-json-and-crm-forms.html

Hope it helps !


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s