Firstly, our crm 2011 is on-premise. Then change to IFD(https://myservername.mycompany.com/ORGName/XRMServices/2011/Organization.svc). when change to IFD, all OData and javascript are not working.
In on-premise, we use for server url...
var lvSz_CRMServerURL = Xrm.Page.Context.getServerUrl();
it is working fine for OData and JS.
In IFD,we use for server url..
var lvSz_CRMODataSvcURLEndpoint = Xrm.Page.context.prependOrgName("/XRMServices/2011/OrganizationData.svc"); Odata and JS function are not working and cannot access.
when use prependOrgName and lvObj_XMLDocHnd2.open("GET", lvSz_ODataQueryURL, true), lvObj_XMLDocHnd2.readyState is 1.(should be 4)
when use prependOrgName and lvObj_XMLDocHnd2.open("GET", lvSz_ODataQueryURL, false), lvObj_XMLDocHnd2.readyState is 4 but lvObj_XMLDocHnd2.status is 404(should be 200). So OData and JS are stopped and not going through the checking.
Please give me any suggestion. what is wrong that may be configuration or JS function.
Please take a look my OData and JS function
.....
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&$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.");
}
}