title: crm 2011 IFD is not working using OData and Javascript
body: <p>Firstly, our crm 2011 is on-premise. Then change to IFD(<a href="https://myservername.mycompany.com/ORGName/XRMServices/2011/Organization.svc" rel="nofollow">https://myservername.mycompany.com/ORGName/XRMServices/2011/Organization.svc</a>). when change to IFD, all OData and javascript are not working.</p>
  
  <p>In <strong>on-premise</strong>, we use for server url...<br>
  var lvSz_CRMServerURL = <strong>Xrm.Page.Context.getServerUrl()</strong>; 
  it is working fine for OData and JS.</p>
  
  <p>In <strong>IFD</strong>,we use for server url..</p>
  
  <p>var lvSz_CRMODataSvcURLEndpoint = <strong>Xrm.Page.context.prependOrgName</strong>("/XRMServices/2011/OrganizationData.svc"); Odata and JS function are not working and cannot access.</p>
  
  <p>when use prependOrgName and lvObj_XMLDocHnd2.open("GET", lvSz_ODataQueryURL, <strong>true</strong>), <strong>lvObj_XMLDocHnd2.readyState</strong> is <strong>1</strong>.(should be 4)</p>
  
  <p>when use prependOrgName and lvObj_XMLDocHnd2.open("GET", lvSz_ODataQueryURL, <strong>false</strong>), <strong>lvObj_XMLDocHnd2.readyState</strong> is <strong>4</strong> but <strong>lvObj_XMLDocHnd2.status</strong> is <strong>404</strong>(should be 200). So OData and JS are stopped and not going through the checking.</p>
  
  <p>Please give me any suggestion. what is wrong that may be configuration or JS function.</p>
  
  <p>Please take a look my OData and JS function </p>
  
  <p>.....</p>
  
  <pre><code>function JS_GenerateQuotation() {
  //debugger;
  var opportunityId = Xrm.Page.data.entity.getId(); //Xrm.Page.getAttribute("new_opportunityid").getValue()[0].id;
  var prepareQuotation;
  
  //var lvSz_CRMServerURL = rootURL + "/GBGroupUAT"; 
  //var lvSz_CRMODataSvcURLEndpoint = lvSz_CRMServerURL + "/XRMServices/2011/OrganizationData.svc";
  
  var lvSz_CRMODataSvcURLEndpoint = Xrm.Page.context.prependOrgName("/XRMServices/2011/OrganizationData.svc");
  
  var lvObj_XMLDocHnd2 = null;
  lvObj_XMLDocHnd2 = new XMLHttpRequest();
  
  var relatedEntity = "opportunity";
  var lvSz_ODataQueryURL = lvSz_CRMODataSvcURLEndpoint + ((relatedEntity == "opportunity") ? "/OpportunitySet?$select=new_PrepareQuotation&amp;$filter=OpportunityId eq guid'" + opportunityId + "'" : "");
  
  lvObj_XMLDocHnd2.open("GET", lvSz_ODataQueryURL, false);
  lvObj_XMLDocHnd2.setRequestHeader("Accept", "application/json");
  lvObj_XMLDocHnd2.setRequestHeader("Content-Type", "application/json; charset=utf-8");
  var lvArr_CRMRecordsMatchingSpecifiedGUID;
  
  lvObj_XMLDocHnd2.onreadystatechange = function () {
      if (lvObj_XMLDocHnd2.readyState == 4) {
          if (lvObj_XMLDocHnd2.status == 200) {
  
              lvArr_CRMRecordsMatchingSpecifiedGUID = eval('(' + lvObj_XMLDocHnd2.responseText + ')');
  
              if (lvArr_CRMRecordsMatchingSpecifiedGUID == null || lvArr_CRMRecordsMatchingSpecifiedGUID == "" || lvArr_CRMRecordsMatchingSpecifiedGUID.d.results[0] == null) {
  
              }
              else {
                  prepareQuotation = lvArr_CRMRecordsMatchingSpecifiedGUID.d.results[0].new_PrepareQuotation;
              }
          }
      }
  }
  lvObj_XMLDocHnd2.send();
  
  if (prepareQuotation != false) {
      var GUIDvalue = Xrm.Page.data.entity.getId();
  
      var serverUrl = urlGenerateQuotation + GUIDvalue;
  
      var features = "location=no,menubar=no,status=no,toolbar=no,resizable=1";
      window.open(serverUrl, "_blank", features);
  }
  else {
      alert("Please prepare quotation.");
  }
  </code></pre>
  
  <p>}</p>