Access MS CRM 2011 with IP address ,can get Odata Java Script Query Results

Access MS CRM 2011 with IP address ,can get Odata Java Script Query Results:


Some times we may access the CRM with IP address as below.AccessCrmWithIp


At this point of time CRM Javascript  Xrm.Page.context.getServerUrl() cant get the Server Url. To over come this use the following Java Script code to get the Server Url.

var serverUrl = document.location.protocol + “//” + + “/” + Xrm.Page.context.getOrgUniqueName(); 

This will work fine for the both IP and CRM Serverl Urls.

Please have a glance the below example.

Below i am commenting var serverUrl = Xrm.Page.context.getServerUrl();

function OdataRetrieveMultipleUsingJquery(ODataFilterQuery) {
//var serverUrl = Xrm.Page.context.getServerUrl();

var serverUrl = document.location.protocol + “//” + + “/” + Xrm.Page.context.getOrgUniqueName();
var Odata_OrgName = “/xrmservices/2011/OrganizationData.svc”;
var oDataUri = serverUrl + Odata_OrgName + ODataFilterQuery;
var jSonArray = new Array();

type: “GET”,
contentType: “application/json; charset=utf-8”,
datatype: “json”,
url: oDataUri,
async: false,
beforeSend: function (XMLHttpRequest) {
//Specifying this header ensures that the results will be returned as JSON.
XMLHttpRequest.setRequestHeader(“Accept”, “application/json”);
success: function (data, textStatus, XmlHttpRequest) {
if (data && data.d != null) {
error: function (XmlHttpRequest, textStatus, errorThrown) {
alert(“Invalid Record Selection or No Record found with the Search Item”);

return jSonArray;


Hope this helps you.




Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s