Freigeben über


CRM 2011 Sub Grid Refresh

In CRM 2011 there is the new native feature of being able to place a sub grid in a form. It is very common that on the form you have a total or summary field that you want updated when data is added, updated or removed from the sub grid.

The following code worked nicely with the RTM version of CRM 2011.

  var grid = document.getElementById("InvolvedPartiesGrid"); 
 if (grid) { 
 grid.attachEvent("onrefresh", CheckInvolvedParties); 
 } else { 
 alert("Grid is null"); 
 }
 

However after Rollup 1 it seems that the grid variable was coming up null. This is because the gird is still loading when the onload event fires. Here is a workaround until this is fixed in a newer rollup.

 function Form_OnLoad() 
{ 
 //Attach to the grid refresh event 
 setTimeout("SetupGridRefresh();", 2500); 
} 
 
function SetupGridRefresh() { 
 var grid = document.getElementById("InvolvedPartiesGrid"); 
 if (grid) { 
 grid.attachEvent("onrefresh", CheckInvolvedParties); 
 } else { 
 alert("Grid is null"); 
 } 
} 
 
function CheckInvolvedParties() 
{ 
 window.location.reload(true); 
}
 

Comments

  • Anonymous
    January 01, 2012
    did you notice that the print preview is getting the grid with all records (WITHOUT THE APPLIED FETCH FILTER), how to resolve that ?

  • Anonymous
    January 01, 2012
    did you notice that the print preview is getting the grid with all records (WITHOUT THE APPLIED FETCH FILTER), how to resolve that ?

  • Anonymous
    March 03, 2012
    I have tried the same code it works fine but however after Installing Rollup 6 . The event becomes infinite loop