CRM 2011 – How to refresh a form after subgrid changes
By Joe GillPublished On 8th June 2011
SubGrids are a great improvement which were added in CRM 2011 that allow you to easily add a grid of related entities to a form rather than navigating from the left menu. Here is a simple example of how to refresh the parent form when an update to the subgrid has occurred.
In my example updates to the results records trigger a call out which updates the average mark on the contact record so I want to redisplay the contact form after any changes to the subgrid.
First I added the sub grid to my contact form in the usual way
I then added the following Javascript to fire when contact form loads
function ContactLoad() { var grid = document.getElementById(“ExamResults”); grid.attachEvent(“onrefresh”, ReLoadContact); } function ReLoadContact() { window.location.reload(true); }
The Javascript simply attaches an event hander to the subgrid refresh event so that the function ReloadContact get called when the sub grid refreshes. As I said this is a simple example and another way would be to do an OData call from Javascript and update the required parent form field.