0

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:

enter image description here

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.

6
  • 1
    Those aren't errors, they're warnings. The second one is because of your use of async: false which needs to be removed. I'd suggest you check the network tab of the console after making the request to see what the response code and text is. If the request is failing it should hopefully give you a useful error message you can debug Commented Jul 13, 2018 at 10:56
  • hey @RoryMcCrossan I have removed async:false but still it won't able to call some how. is there any mistake in request? Commented Jul 13, 2018 at 12:00
  • @RoryMcCrossan I have one question that should we have to allow CORS in CRM to call organization service from javascript? Commented Jul 13, 2018 at 12:30
  • 1
    Within CRM form, CORS not at all needed for CRM service calls. Did you debug & see odataUri value? Commented Jul 13, 2018 at 12:41
  • @ArunVinoth I have checked the URl and here it is ServerAddress/OrganizationName/xrmservices/2011/… Commented Jul 13, 2018 at 13:00

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

I have now write new_plugins_configurationset but now it's givig me cross origion error even tough I am calling CRM through CRM contact form
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at server/organizationname/xrmservices/2011/organizationdata.svc/…. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). this is the error now I am getting
what I want to achieve is on opening of one entity form I want field of another entity to be set in a control of opening entity.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.