locked
upgrading jscript to work with CRM 2013 (from CRM 2011 online) question RRS feed

  • Question

  • I have few web-resource written in CRM 2011 online and it seems some of jscripts may not work with CRM 2013.  How could we upgrade the scritpt or find the correct methods to use. Appreciate your help.  It seems the following may not work - the ones italized as below:

     crmForm.all.address1_postalcode.DataValue;

    Xrm.Page.getAttribute("new_source").getSelectedOption().text;

     accountLookup.DefaultValue[0].data = accountLookup.getValue()[0].data;

    Tuesday, September 24, 2013 10:35 PM

Answers

  • for "crmForm.all.address1_postalcode.DataValue;" you can use:

    var postalcode = Xrm.Page.getAttribute("address1_postalcode").getValue();

    instead of "Xrm.Page.getAttribute("new_source").getSelectedOption().text;" you need to use

    Xrm.Page.getAttribute("new_source").getText();

    and for the last one I don't know what is your requirement but if you want to set a lookup value in another lookup of the same type you can do with this code:

    var accountValue = Xrm.Page.getAttribute("sourcefield").getValue();
    Xrm.Page.getAttribute("targetfield").setValue(accountValue);


    My blog: www.crmanswers.net

    • Marked as answer by CRM elite Wednesday, September 25, 2013 9:13 PM
    Tuesday, September 24, 2013 11:18 PM

All replies

  • for "crmForm.all.address1_postalcode.DataValue;" you can use:

    var postalcode = Xrm.Page.getAttribute("address1_postalcode").getValue();

    instead of "Xrm.Page.getAttribute("new_source").getSelectedOption().text;" you need to use

    Xrm.Page.getAttribute("new_source").getText();

    and for the last one I don't know what is your requirement but if you want to set a lookup value in another lookup of the same type you can do with this code:

    var accountValue = Xrm.Page.getAttribute("sourcefield").getValue();
    Xrm.Page.getAttribute("targetfield").setValue(accountValue);


    My blog: www.crmanswers.net

    • Marked as answer by CRM elite Wednesday, September 25, 2013 9:13 PM
    Tuesday, September 24, 2013 11:18 PM
  • Hi Guido Preite, Thanks for your help. Also I have the folowing shown as potential errors. Any thoughts on this would be appreciated. 

    The occurrence of GenerateAuthenticationHeader was located 1 time(s) in this web resource.  -->  var xmlAuthHeader = GenerateAuthenticationHeader();
    The occurrence of ActiveXObject( was located 1 time(s) in this web resource.

    The occurrence of crmForm.all  in here. -> crmForm.all.IFRAME_map.src = MapURL; 

    The occurrence of .ObjectTypeCode -->  crmForm.ObjectTypeCode

    also I am using a function (i believe written by one of the forum member here) 

    ActiveXObject, selectSingleNode & selectNodes are not compatible. 

     //call function to create Soap Request to ms crm webservice
        xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
        xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
        xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
        xmlHttpRequest.send(xml);
        resultXml = xmlHttpRequest.responseXML;
        var errorCount = resultXml.selectNodes('//error').length;
        if (errorCount != 0) {
            var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
            alert("Error Message : " + msg);
        }
        else {
            return resultXml;
        }

    • Edited by CRM elite Wednesday, September 25, 2013 9:58 PM
    Wednesday, September 25, 2013 9:35 PM
  • The SDK has sample code for common CRM CRUD operations in SDK.Rest.js. The code is updated to handle cross-browser compatibility and it would be advisable to go ahead and change your code to instead call methods of this library.

    ActiveXObject is not compatible with non-IE browsers and therefore is not unsupported.

    HTH

    Sam


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Proposed as answer by Guido PreiteMVP Thursday, September 26, 2013 9:54 AM
    Thursday, September 26, 2013 5:25 AM
  • Sir,

    Other Errors like GenerateAuthenticationHeader();, crmForm.all  are they supported but not compatible with non-IE Browsers...?

    Tuesday, October 1, 2013 6:23 AM
  • I tried to get cell value from sub grid and same code seems to be working.

    Have you tried to debug your code ? what line it's breaking ?


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

    Tuesday, December 3, 2013 2:23 AM