locked
why this simple script didn't work (attachEvent) RRS feed

  • Question

  • hi i am using CRM 2011. i just want to alert a message after a contact in the contact subgrid. i am using this

    function Form_onload() {
    //Set Action on subgrid Refresh
    var subGrid = document.getElementById("gggg");
    if (subGrid) {
    subGrid.attachEvent("onrefresh",fnGridRefresh);

    }

    }

    //This function fires on subgrid refresh

    function fnGridRefresh(){

    alert(“Grid refreshed!!!!”);

    }

    which is copy from http://rajeevpentyala.wordpress.com/tag/onrefresh/

    i put Form_onload in the onload event.

    firstly, if i use document.getElementById, it return null.

    then i try to change getElementById to getElementsByTagName.

    but getElementsByTagName has NO attachEvent function.

    do anyone know why ? (as there is so many articles talking this method is worked)

    thanks.


    a

    Wednesday, October 17, 2012 9:24 AM

Answers

  • Hi,

    here is the sample code

    function SubGridLoad() {
        var grid = document.getElementById("gggg");
        if (!grid) {
            setTimeout('SubGridLoad()', 2500);
            return;
        }
        else {
            grid.attachEvent("onrefresh", fnGridRefresh);
            return;
        }

    }
    function fnGridRefresh() {
       alert("Grid refreshed!!!!");
    }

    • Proposed as answer by _Vikram Wednesday, October 17, 2012 9:40 AM
    • Marked as answer by verystupidguy Thursday, October 18, 2012 7:25 AM
    Wednesday, October 17, 2012 9:38 AM

All replies

  • Hello,

    First thing that I see is that you are using wrong quotes in your code - you should replace “” with " or '.

    Second. getElementsByTagName method returns array of retrieved objects so you should work with it as with array.

    Third. This kind of functionality is not supported because DOM object model is used.


    Freelance Developer for Dynamics CRM 4.0/2011

    Wednesday, October 17, 2012 9:30 AM
    Moderator
  • Hi,

    here is the sample code

    function SubGridLoad() {
        var grid = document.getElementById("gggg");
        if (!grid) {
            setTimeout('SubGridLoad()', 2500);
            return;
        }
        else {
            grid.attachEvent("onrefresh", fnGridRefresh);
            return;
        }

    }
    function fnGridRefresh() {
       alert("Grid refreshed!!!!");
    }

    • Proposed as answer by _Vikram Wednesday, October 17, 2012 9:40 AM
    • Marked as answer by verystupidguy Thursday, October 18, 2012 7:25 AM
    Wednesday, October 17, 2012 9:38 AM