Error in Javascript function nextsibling in crm 2013 RRS feed

  • Question

  • Hi,

                i am using crm 2013, in the CRM i am having several JavaScript functions, the below functions are not working in crm.

    1. crmGrid_

    2. In another script i am using nextsibling"  function also giving error as below

    Please help me in this issue.


    Tuesday, October 15, 2013 10:36 AM

All replies

  • You should probably post your code and explain what you are trying to accomplish. 

    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Tuesday, October 15, 2013 1:06 PM
  • Hi Jason,

       Thanks fro the reply, Here is the code i am posting:


    //NOTE: Search and replace the following fields with your fields.
    //Options Set = new_productrange
    //Multi Select Save field = new_productrange_value
    //Start ---------------- Multi Select Picklist ---------------------
    //Update >> Provide schemaname for picklist field
    var var_new_picklist = 'new_productrange';
    //Update >> Provide schemaname for field which will store the multi selected values for picklist
    var var_new_picklistvalue = 'new_productrange_value';
    //Method to convert picklist to multi select picklist
    function ConvertToMultiSelect()
    // PL - the picklist attribute; PLV - used to save selected picklist values
    //Update >> Provide picklist schema name
    var PL =Xrm.Page.getAttribute("new_productrange").getValue() ;
    //Update >> Provide field name which will store the multi selected values for picklist
    var PLV =Xrm.Page.getAttribute("new_productrange_value").getValue();
    if( PL != null && PLV != null )
      PL.style.display = "none";
      // Create a DIV container
        var addDiv = document.createElement("div");
      addDiv.setAttribute("style", "overflow-y:auto; height:90px; border:1px #6699cc solid; background-color:#ffffff;");
      // Initialise checkbox controls
      for( var i = 1; i < PL.options.length; i++ )
        var pOption = PL.options[i];
        if( !IsChecked( pOption.text , PL, PLV) ){
          var addInput = document.createElement("input" );
           addInput.setAttribute("style","border:none; width:25px; align:left;");
          var addInput = document.createElement("input" );
          addInput.setAttribute("style","border:none; width:25px; align:left;");
        var addLabel = document.createElement( "label");
        addLabel.innerText = pOption.text;
        var addBr = document.createElement( "br"); //it's a 'br' flag
    }//end of if
    }//end of function
    ///////Supported functions
      // Check if it is selected
      function IsChecked( pText , PL, PLV)
        if(PLV.value != "")
          var PLVT = PLV.value.split(";");
          for( var i = 0; i < PLVT.length; i++ )
            if( PLVT[i] == pText )
              return true;
        return false;
      // Save the selected text, this field can also be used in Advanced Find
      function OnSave()
        //Update >> Provide picklist schema name
        var PL = Xrm.Page.getAttribute("new_productrange").getValue();
        var getInput = PL.nextSibling.getElementsByTagName("input");
        var result = '';
        for( var i = 0; i < getInput.length; i++ )
          if( getInput[i].checked)
            result += getInput[i].nextSibling.innerText + ";";
        //save value
        control = Xrm.Page.getControl(var_new_picklistvalue);
        attribute = control.getAttribute();
      }//end of function OnSave()
    //End ---------------- Multi Select Picklist ---------------------


    Here we are trying to convert normal dropdown field to multiselect checkbox list, but after selecting multiple values and saving it, it is  showing the above error.


    Tuesday, October 15, 2013 1:23 PM
  • Hi There.

    Accessing DOM will not be supported in CRM 2013. Explanation from SDK. You will need to find an alternative way to do it or use just the out-of-box function


    Changes to the Document Object Model (DOM)

    The next release of Microsoft Dynamics CRM will make many changes in the Document Object Model (DOM). Writing JavaScript code that modifies the DOM is not supported and you should expect that any scripts written using Microsoft Dynamics CRM application page DOM elements will break.




    Tuesday, October 15, 2013 2:01 PM
  • Hi Jaimie,

        Thanks for your reply, what are the DOM components in the code, and what i need to change, is there any alternative codes for this.

        Please suggest me how to do this.


    Wednesday, October 16, 2013 8:31 AM
  • E.g.

     function OnSave()
        //Update >> Provide picklist schema name
        var PL = Xrm.Page.getAttribute("new_productrange").getValue();
        var getInput = PL.nextSibling.getElementsByTagName("input");

    Here you are trying to get DOM Elements and modify those directly. There is no direct supported way to change rendering of existing control on form.

    You can achieve this by defining newcontrol in separate webpage as web resource and embedding that in form. Now you have to take care of its Save\Selection in client side.

    Wednesday, October 16, 2013 9:35 AM
  • Hi Niraj,

         If we add a new web resource and embedded in a form, is it show any effect on the already existed opportunities?



    Wednesday, October 16, 2013 2:08 PM
  • Hi Nagaraj,

    I am not able to understand your question. What kind of effect you suspect on existing opportunities?

    If a web resource is embedded in form than it will start showing on all opportunities.

    Thursday, October 17, 2013 3:38 AM