My JavaScripts are not working in CRM 13 - control is undefined RRS feed

  • Question

  • Here is my js:

     var gridControl = Xrm.Page.ui.controls.get("SubGrid2");  gridControl.refresh();

    I'm receiving all the time this message:

    Unable to get property 'refresh()' of undefined or null reference

    I'm receiving this messages in every use of the CRM JS objects.  CRM 13 JS functions doesn't work...

    Thursday, September 25, 2014 12:40 PM

All replies

  • OK I think I have found solution


    Thursday, September 25, 2014 1:25 PM
  • Hi ,

    It is not about that ı guess. Subgrids loads asynchronous so that u have to check it is null or not.

    function OnLoadEventOfTheMainForm() {

    var SubGrid = document.getElementById("SubGrid2"); if (SubGrid == null) { setTimeout(function () { OnLoadEventOfTheMainForm(); }, 2000); //if the grid hasn’t loaded run this again when it has return; } SubGrid.control.Refresh(); //refresh the sub grid using the new fetch xml }

    Polat Aydın Crm Software Developer

    Thursday, September 25, 2014 1:29 PM