locked
Probleam in accessing Dom elements using Jquery RRS feed

  • Question

  • Hello,

    i have a Custom plugin for opportunity entity. Every thing working good with CRM 2013 but Same things not working in CRM 2013 . i have run custom validation tool and no any issues found in javascript file. i am facing  Probleam in accessing Dom elements using Jquery or Javascript.

    Regards,

    Akshay

    Wednesday, January 29, 2014 7:22 AM

All replies

  • Hi

    Modifying or accessing dom elements is not a supported customisation. I am not sure why validation tool did not show any error.

    If you have done any such code in js you have two options :

    1. Switch to supported customization or

    2. Go through dom structure of crm 2013 and tweak your code (This is unsupported)

    Post your code if you need any specific help

    Wednesday, January 29, 2014 2:18 PM
  • Hi,

    below are customized code which i used

    function changecheckliststyle()
    {
        var checklistsectionMain =
            $("#tab3 .ms-crm-FormSection-Container");


        if (checklistsectionMain != null && checklistsectionMain != undefined)
        {
            for (var count = 0; count < checklistsectionMain.length ; count++)
            {

                var checklistsection = checklistsectionMain.item(count);
                if (checklistsection != undefined)
                {
                    var table = checklistsection.getElementsByTagName("table");
                    if (table != undefined) {
                        table[0].removeAttribute("style");
                    }

                    var controlarray = new Array();
                    controlarray = checklistsection.getElementsByClassName("ms-crm-FieldLabel-LeftAlign  FormSection_CellPadding ms-crm-Field-Normal");
                    controlarray[0].style.width="450px";
                }


            }

        }
    }

    Wednesday, January 29, 2014 4:17 PM
  • The validation tool does not look for jQuery references to every possible DOM element and class name from 2011, and those items are NOT guaranteed to always stay the same - that's a big reason why accessing them like this is unsupported. So when you access '#tab3.ms-crm-FormSection-Container' via jQuery for example, that won't get flagged as non-compliant javascript by the validation tool. As already mentioned by others, this kind of customization is unsupported so if it works in 2011 but not in 2013, the first guess is that the referenced item no longer exists or has a different id/name in 2013. If you debug the JS you will probably find that your checklistsectionMain is not getting set because the exact element being searched for doesn't exist in 2013.
    Wednesday, January 29, 2014 6:54 PM