locked
Crm 2011 outlook offline javascript request get 404 error: cannot located OrganizationData.svc RRS feed

  • Question

  • my JavaScript  can work fine online.

    but not offline:

    offline ODataPath is :

    "http://localhost:2525/DTCRM/XRMServices/2011/OrganizationData.svc"

    How can id resolve this problem.

    I will put full code under.

    Beside Our CRM 2011 update to rolling update6 on server.

    but outlook client cannot setup rolling update. my outlook is outlook 2010. get error in fist setep when update rolling 5: CRM2011-Client-KB2567454-CHS-i386.exe


    • Edited by haoyujie Monday, November 18, 2013 1:48 AM fix letter
    Monday, November 18, 2013 1:32 AM

All replies



  • // JScript source code

    var ODataPath;
    var serverPro;
    var serverIP;

    serverPro = window.location.protocol ;  //http:
    serverIP = window.location.host;  //crm server ip, in offline = localhost
    ODataPath = serverPro + "//" + serverIP + "/DTCRM/XRMServices/2011/OrganizationData.svc";

    /*---------客户拜访实体,拜访对象带入联系人级别和客户名称----------*/
    init = function () {

        //获取拜访对象信息
       var objContact = Xrm.Page.getAttribute("new_contact").getValue();
         if(objContact!=null&&objContact!=""){
              var sContactId = objContact[0].id;
              retrieveContactRecord(sContactId);//uuid
        }
    }
    //accord guit get contract obj
    retrieveContactRecord = function (id) {

        var retrieveContactReq = new XMLHttpRequest();
         //
        retrieveContactReq.open("GET", ODataPath + "/ContactSet(guid' " + id + " ')", true);
          retrieveContactReq.setRequestHeader("Accept", "application/json");//
        retrieveContactReq.setRequestHeader("Content-Type", "application/json;charset=utf-8");//
          retrieveContactReq.onreadystatechange = function () {//
            retrieveContactReqCallBack(this);
        };
        retrieveContactReq.send();//
    }

    /*wait and return value from server*/
    retrieveContactReqCallBack = function (retrieveContactReq) {

        //以下代码可以参照SDK,先判断准备状态为4时则完成,然后当其状态为200时表示成功,400表示失败
        if (retrieveContactReq.readyState == 4 /* complete */) {

    I get 404 in offline , on line will  succeed.

            if (retrieveContactReq.status == 200) {
                //Success
                var retrievedContact = JSON.parse(retrieveContactReq.responseText).d;//Json获取联系人实体

            var sAccountId = retrievedContact.new_parentcustomerid.Id;//客户id
                var sAccountType = retrievedContact.new_parentcustomerid.LogicalName;//客户字段类型
                var sAccountName = retrievedContact.new_parentcustomerid.Name;//客户名称

                var iContactTypeCode = retrievedContact.new_contacttypecode.Value;//联系人级别
                //为查找类型的客户赋值
            if (!(sAccountName == "" || sAccountName == undefined) && sAccountType == "account") {
                    var Obj = new Object();
                    Obj.id = sAccountId;
                    Obj.entityType = sAccountType;
                    Obj.name = sAccountName;
                    var ObjValue = new Array();
                    ObjValue[0] = Obj;
                    Xrm.Page.getAttribute("new_accountname").setValue(ObjValue);
                    //使只读的客户字段总是可以保存
                    Xrm.Page.getAttribute("new_accountname").setSubmitMode("always");
                } else {
                    Xrm.Page.getAttribute("new_accountname").setValue(null);
                    Xrm.Page.getAttribute("new_accountname").setSubmitMode("always");
                }
               //为联系人级别赋值
            if (!(iContactTypeCode == null || iContactTypeCode == undefined)) {
                    Xrm.Page.getAttribute("new_contacttypecode").setValue(parseInt(iContactTypeCode));
                    Xrm.Page.getAttribute("new_contacttypecode").setSubmitMode("always");

                } else {
                    Xrm.Page.getAttribute("new_contacttypecode").setValue(null);
                    Xrm.Page.getAttribute("new_contacttypecode").setSubmitMode("always");
                }

            } else {//错误
                errorHandler(retrieveContactReq);
            }
        }
    }


    //error deal
    errorHandler = function (XmlHttpRequest) {
        showMessage("Error: " +
            XmlHttpRequest.status + ":" +
            XmlHttpRequest.statusText + ":" +
            JSON.parse(XmlHttpRequest.responseText).error.message.value);
    }

       
    Monday, November 18, 2013 1:37 AM
  • Hi,

    Change your OdataPath code like as below :

    var serverUrl = Xrm.Page.context.getServerUrl();
    var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
    Vikram !

    Monday, November 18, 2013 1:44 AM
  • Sorry for late back.

    Thank your answers.

    BUT it not work. Because the OdataPath same with before:

    offline get 404

    Monday, November 18, 2013 5:50 AM
  • Just offline failed.

    Online is fine.

    And , I saw a article:

    http://social.msdn.microsoft.com/Forums/en-US/30d5bc6b-a04b-4f16-bf1c-1f24b0dcb524/error-404-while-working-offline-outlook-client-with-dynamics-crm-40?forum=crmdeployment

    He said that maybe a crm design bug.

    System user not sync to local.

    and that gay's description too sample, i can't get point.

    Monday, November 18, 2013 5:56 AM