locked
MS CRM 2011 to MS CRM 2013 endpoints RRS feed

  • Question

  • Hello, All!

    I need a helping hand. I am upgrading our MS CRM 2011 to MS CRM 2013. I have ran the Custom Code Validation Tool and the Legacy Check Feature. Most importantly, I need to change the CRM 4.0 endpoints to the new CRM 2013 compatible endpoints and I feel a little confused. Most of the scripts I have to upgrade are similar to this one. 

    My big questions are: http://schemas.xmlsoap.org/soap/envelope/\ ---- What do I change this to?
    http://schemas.microsoft.com/crm/2007/WebServices\ ---- Same question
    http://schemas.microsoft.com/crm/2006/Query\ ---- Same question
    http://www.w3.org/2001/XMLSchema-instance\ ---- Same question
    /mscrmservices/2007/crmservice.asmx ---- Same question


    function Mscrm_Isv_lead_Form_Group0_Control0_1(){if (crmForm.IsDirty) { alert('Please save any changes made to the lead before updating.');} else {openIsvWin('/ISV/Hoovers/Login.ashx?ReturnUrl=/HooversWeb//Pages/MergeMatches.aspx', 1, '1', 'dialogWidth: 900px; dialogHeight: 800px; status: off; resizable: 1;', null); if (window.location.href.indexOf('#') > 0) { window.location.href = window.location.href.replace('#', ''); } else { window.location.href = window.location.href + '#' }};}function Mscrm_Isv_lead_Form_Group0_Control1_2(){
     if(CanScheduleUpdate(crmForm.ObjectTypeName, crmForm.ObjectId))
    {
     openIsvWin('/ISV/Hoovers/Login.ashx?ReturnUrl=/HooversWeb/Pages/ScheduleUpdate.aspx', 1, '1', 'dialogWidth: 500px; dialogHeight: 650px; status: off; resizable: 1;', null);
      if (window.location.href.indexOf('#') > 0) {
       window.location.href = window.location.href.replace('#', '');
      }
      else {
       window.location.href = window.location.href + '#';
      }
    }
    else
    {
      alert('Record must be linked to Access Hoover\'s database to schedule an update. Please update the record from Access Hoover\'s and then schedule record update');
     }

    function CanScheduleUpdate(entityName, entityId)
    {
     var canScheduleUpdate = false;
        switch(entityName)
     {
      case "account":
      case "lead":
       var result = Retrieve(entityName, entityId, [ "hoovers_linkedtohoovers" ]);
       if (result.hoovers_linkedtohoovers && result.hoovers_linkedtohoovers.value == 1)
                    canScheduleUpdate = true;
       break;
      case "contact":
       var contactResult = Retrieve(entityName, entityId, [ "parentcustomerid" ]);
       if (contactResult.parentcustomerid != null && contactResult.parentcustomerid.type == "account")
       {
        var result = Retrieve("account", contactResult.parentcustomerid.value, [ "hoovers_linkedtohoovers" ]);
        if (result.hoovers_linkedtohoovers && result.hoovers_linkedtohoovers.value == 1)
                        canScheduleUpdate = true;
       }
       break;
     }

        return canScheduleUpdate;
    }

    function Retrieve(entityName, entityId, fields)
    {
     var result = {};

     var xml = "";
     xml += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
     xml += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
     xml += GenerateAuthenticationHeader();
     xml += "<soap:Body><Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">";
     xml += "<entityName>" + entityName + "</entityName>";
     xml += "<id>" + entityId + "</id>";
     xml += "<columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:ColumnSet\"><q1:Attributes>";

     for (var i = 0; i < fields.length; i++)
     {
      xml += "<q1:Attribute>" + fields[i] + "</q1:Attribute>";
     }

     xml += "</q1:Attributes></columnSet>";
     xml += "</Retrieve></soap:Body>";
     xml += "</soap:Envelope>";
     
     var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     xmlHttp.open("POST", "/mscrmservices/2007/crmservice.asmx", false);
     xmlHttp.setRequestHeader("Content-Type", "text/xml; charset-utf-8");
     xmlHttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
     xmlHttp.send(xml);
     
     var responseXml = xmlHttp.responseXml;

     var retrieveResultNode = responseXml.selectSingleNode("soap:Envelope/soap:Body/RetrieveResponse/RetrieveResult");

     if (retrieveResultNode)
     {
      result = deserializeBusinessEntityIntoObject(retrieveResultNode, fields);
     }

     return result;
    }

    function deserializeBusinessEntityIntoObject(businessEntityXmlNode, fields)
    {
     var result = {};

     // Create a new property for each field passed in.  This way, if it's null and not returned by CRM, we'll still have
     // the property in the result object.
     for (var i = 0; i < fields.length; i++)
     {
      result[fields[i]] = { value: null, DataValue: null };
     }

     if (businessEntityXmlNode && businessEntityXmlNode.childNodes && businessEntityXmlNode.childNodes.length > 0)
     {
      for (var i = 0; i < businessEntityXmlNode.childNodes.length; i++)
      {
       var isDate = false;
       var isNumber = false;
       var isLookup = false;
       var isPicklist = false;

       var childNode = businessEntityXmlNode.childNodes[i];
       var fieldName = childNode.tagName.replace("q1:", "");
       var fieldValue = childNode.text;

       result[fieldName] = {};

       for (var j = 0; j < childNode.attributes.length; j++)
       {
        var attributeName = childNode.attributes[j].nodeName;
        var attributeValue = childNode.attributes[j].nodeValue;

        result[fieldName][attributeName] = attributeValue;

        if (attributeName == "date")
        {
         isDate = true;
        }
        else if (attributeName == "formattedvalue" && !isNaN(fieldValue))
        {
         isNumber = true;
        }
        else if (attributeName == "dsc")
        {
         isLookup = true;
        }
        else if (attributeName == "name")
        {
         isPicklist = true;
        }
       }

       var formattedValue = fieldValue;
       if (isDate)
       {
        formattedValue = new Date(result[fieldName].date + " " + result[fieldName].time);
       }
       else if (isNumber)
       {
        formattedValue = parseFloat(formattedValue);
       }
       else if (isLookup)
       {
        formattedValue = {
         id: fieldValue,
         typename: "",
         name: result[fieldName].name
        };
       }
       else if (isPicklist)
       {
        formattedValue = parseInt(formattedValue);
       }

       result[fieldName].value = fieldValue;
       result[fieldName].DataValue = formattedValue;
      }
     }

     return result;
    }  
    }function Mscrm_Isv_lead_Form_Group0_Control4_3(){if (crmForm.IsDirty) { alert('Please save any changes made to the lead before removing the Hoover\'s link.');} else {openIsvWin('/ISV/Hoovers/Login.ashx?ReturnUrl=/HooversWeb/Pages/ConfirmRemoveLink.aspx', 1, '1', 'dialogWidth: 350px; dialogHeight: 200px; status: off; resizable: 1;', { parentWin: window }); if (window.location.href.indexOf('#') > 0) { window.location.href = window.location.href.replace('#', ''); } else { window.location.href = window.location.href + '#' }};}
    Wednesday, July 23, 2014 3:42 PM

All replies

  • Hi,

    CRM 2013 removed the support for 2007 SOAP endpoint. The 2011 REST API (OData) was introduced. Whatever code you have using SOAP will need to be completely re-written using the REST API, there is no short-cut for this. See this MSDN article for examples. 


    Admin QuikView Solution for CRM 2013

    Thursday, July 24, 2014 4:54 AM