简体   繁体   中英

Fetching Record from CRM 2011 using jQuery/javascript

I am trying to get data from CRM 2011 through jQuery but I am unable to fetch the data. Here is my code:

function GetConfigurations() {

var oDataPath = Xrm.Page.context.getServerUrl() + "/xrmservices/2011/organizationdata.svc";

    var filter = "/new_plugins_configurationSet?" +

  "$top=1";

var dataUrl=oDataPath + filter;
alert(dataUrl);

try
{
     $.ajax({url: dataUrl, success: function(result){
            alert(result);
        },error:function(error){console.log(error);alert("error");}});
}
catch(err)
{
    alert("error" + err.message);
}



}

This gives me the following error in the console of the CRM form:

在此处输入图片说明

Am I doing something wrong in the code?

Edited :

I have done changes in Js Code and now I am writing new_plugins_configurationset but it is returning Cross origin error even tough I am calling JS Code from CRM forms.

Here what I want to achieve is that on opening of one Entity CRM form, I want to read a second entity and put value in control of opening entity. that's why I am calling second entity using JS code.

The issue is with dataset name, it should end with Set keyword. For your entity it should be new_plugins_configurationSet .

I have resolved my problem. I was doing following mistakes through which I was unable to Get data from CRM.

  • The issue was with dataset name, it should end with Set keyword. For my entity it should be new_plugins_configurationSet.

  • I was using Xrm.Page.context.getServerUrl(); method to get serverUrl but by using this it's returning Cross origin error, so I used Xrm.Page.context.getClientUrl() to get complete server Url.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM