Monday, December 21, 2009

Hooking into the CRM Grid Refresh

For those of us who heavily extend CRM with javascript, there is an event handler I've just found and used for a project that I'm working on that allows you to hook into the refresh of a crmGrid object.  This is an example of how to use the event:

function GridRefresh () {
  alert("The grid has refreshed.");

document.all.crmGrid.attachEvent("onrefresh", GridRefresh);

UPDATE: I discovered recently that this event will not be triggered in the event of a view change.  As near as I can tell, there is no event that is triggered when the view is changed.

Monday, December 14, 2009

Fire an event on any CRM field change

The following code shows how you can attach any function to all of the fields on a CRM form for execution when any of them change.  It's based on Michael Höhne's code to find all fields on a form:

FieldChange = function () {

for (var index in crmForm.all) {
  var control = crmForm.all[index];
  if (control.req && (control.Disabled != null)) {
    control.attachEvent("onchange", FieldChange);