locked
JavaScript issue with UR 13 update RRS feed

  • Question

  • Hello All,

    We recently upgraded to UR13 and we found few Scripts are breaking, using the Code Validation tool we identified the Scripts and the Group matching pattern. We found that one of the script is using ‘crmGrid’ into it and breaking in IE but was doing ok in UR10.

    Using the code validation tool i found it belongs to Red Group matching patterns.

    How to fix this issue, what needs to be used instead ‘crmGrid’, the tool do not suggest anything for fixes just showing the potential errors. Also, we have few in Blue Group like 'Selected text' property.

    Can someone please suggest me what we can use instead of ‘crmGrid’ and 'SelectedText'.

    Thank You looking into my Post.

    I need urgent help, please post your valuable suggestions.


    Puneet Joshi - Dynamics CRM Developer

    Wednesday, June 26, 2013 5:59 PM

All replies

  • Hi Puneet. I'm not aware of crmGrid being a standard JavaScript object. It may be that it refers to a variable, perhaps one specified in a separate web resource. Can you post some code.


    Paul Developer of Summary Plus for Dynamics CRM. http://www.clew-consulting.com/summaryplus

    Thursday, June 27, 2013 11:39 AM
  • Hello Paul,

    I am putting the scripts here...

    Red Category Issues on the below code: showing these properties in Red in the code "crmGrid"

    //If the SDK namespace object is not defined, create it.
    if (typeof (variablename) == "undefined")
    { variablename = {}; }
    // Create Namespace container for functions in this library;
    variablename.setactivitiestoall = {
        set: function (defaultValue) {
            if (defaultValue == null) {
                defaultValue = 'All';
            }
            switch (Xrm.Page.data.entity.getEntityName()) {
                case 'account':
                    this.setview('Activities', defaultValue, 'crmGrid_Account_ActivityPointers_datefilter');
                    break;
                case 'contact':
                    this.setview('Activities', defaultValue, 'crmGrid_Contact_ActivityPointers_datefilter');
                    break;
                case 'opportunity':
                    this.setview('Activities', defaultValue, 'crmGrid_Opportunity_ActivityPointers_datefilter');
                    break;
                default:
                    alert('variablename.setactivitiestoall cannot be called on entity of type"' & Xrm.Page.data.entity.getEntityName() & '"');
            }
        },
        setview: function (type, defaultValue, fieldName) {
            SetDefaultView = function (viewCombo, viewName, appGrid) {
                if (viewCombo.value != viewName) {
                    viewCombo.value = viewName;
                    appGrid.RefreshGridView();
                }
            }
            if (document.getElementById("nav" + type) != null) {
                document.getElementById("nav" + type).onclick = function () {
                    // loadarea is a MSCRM Function set for onclick of the type of button
                    loadArea("area" + type);
                    // so the rest of his function is added on
                    document.frames("area" + type + "Frame").document.onreadystatechange =
                    function () {
                        if (this.readyState == "complete") {
                            var frame = document.frames("area" + type + "Frame");
                            if (frame != null) {
                                var viewCombo = frame.document.getElementById(fieldName);
                                var appGrid = frame.document.getElementById("AppGridFilterContainer");
                                if (viewCombo != null && appGrid != null) {
                                    if (viewCombo.readyState == "complete") {
                                        SetDefaultView(viewCombo, defaultValue, appGrid);
                                    }
                                    else {
                                        viewCombo.onreadystatechange = function () {
                                            if (this.readyState == "complete") {
                                                SetDefaultView(this, defaultValue, appGrid);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        _x: {
        }
    }

    Blue Category Issues on the below code: showing these properties in blue, .SelectedText, .DataValue and .Text

    function PartPicklistOneOnchange(context)
     {
        var picklistOneAttribute = "First Picklist Schema Name"; // replace with your name of the first picklist
        var picklistTwoAttribute = "Second Picklist Name";  //replace with the name of the picklist with dynamic values
        var picklistOne = document.getElementById(picklistOneAttribute);
        var picklistTwo = document.getElementById(picklistTwoAttribute);
        //Getting the selected value from Picklist One
        var picklistOneSelectedValue = picklistOne.SelectedText
        //This "if" statement stores the original values from the dynamic picklist.
        //Very important if the user hasn't made a selection on the first picklist or if the selection changes
        if (picklistTwo.flag == true)
        
        {
            picklistTwo.Options = picklistTwo.originalPicklistValues;
        }
        else
        
        {
            picklistTwo.originalPicklistValues = picklistTwo.Options;
            picklistTwo.flag = true;
        }
        if (picklistOneSelectedValue != null) {
            for (var i = picklistTwo.length - 1; i >= 0; i--) {
                if (picklistTwo.Options[i].DataValue != null && picklistTwo.Options[i].DataValue != "") {
                    //BEGIN: If the picklist is set to Part I
                    if (picklistOneSelectedValue == "Option Set Value")
                    
                        {
                        //Remove the values
                             if (picklistTwo.Options[i].Text == "some value"
                             || picklistTwo.Options[i].Text == "some value"
                             || picklistTwo.Options[i].Text == "some value"
                             || picklistTwo.Options[i].Text == "some value")
                        {
                        
                        picklistTwo.remove(i);
                        }
                    }
                    //END: Part I Selection   
                    //BEGIN: If the picklist is set to Part II   
            }
        }
    } //End function

    Blue Category Issues on the below code: showing these properties in blue in the code "ActiveXObject"

    function GetRequestObject()
    {
      if (window.XMLHttpRequest)
      {
        return new window.XMLHttpRequest;
      }
      else
      {
        try
        {
          return new ActiveXObject('MSXML2.XMLHTTP.3.0');
        }
        catch (ex)
        {
          return null;
        }
      }
    }

    Blue Category Issues on the below code: showing these properties in blue in the code ".text";

    function hidefield()
    {
        var type = Xrm.Page.getAttribute("field’s schema name").getSelectedOption().text;
        if (type == "Local Govt") {
               Xrm.Page.getControl("another field’s schema name ").setVisible(true);
            
        }
        else {
            Xrm.Page.getControl("another field’s schema name").setVisible(true);
        }
    }

    It would be great if you suggest me something.


    Puneet Joshi - Dynamics CRM Developer

    Thursday, June 27, 2013 2:43 PM
  • As far as I'm aware, the use of crmGrid in client script has never been officially supported, which is why there are no suggested fixes

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Thursday, June 27, 2013 4:02 PM
    Moderator
  • crmGrid falls into Red Group issue and as per your suggestion i will take another route if possible, Do you have any suggestions for Blue Group issues. Please.

    Puneet Joshi - Dynamics CRM Developer

    Thursday, June 27, 2013 4:08 PM
  • I found this link useful for fixing one of the Red Group issue to Default the Filter to All.

    http://www.magnetismsolutions.com/blog/paul-nieuwelaars-blog/2013/01/11/default-activity-filter-on-to-all-dynamics-crm-2011-ur12


    Puneet Joshi - Dynamics CRM Developer

    Sunday, July 14, 2013 5:46 PM
  • Hi Puneet,

        I am also facing the same issue, your solution is for crm 2011, i am using CRM 2013, how to replace the "crmGrid_" function in CRM 2013.

        Is there any tool to convert CRM 2011 javascripts to CRM 2013 codes. 

        Please help me in this issue.

        Thanks in advance,


    Nagaraj


    Tuesday, October 15, 2013 11:32 AM
  • No idea about CRM 2013, i have not seen 2013 yet.

    Puneet Joshi - Dynamics CRM Developer

    Thursday, October 17, 2013 4:29 PM