Wednesday, October 6, 2010

MS CRM field events with bulk update

This is a good news /bad news story. I have a form that is heavily modified and has 1k lines of JavaScript (JS) code behind it. The good news is that it has a bunch of functionality that really makes the system sing - the bad news is that when you put code behind each field's OnChange event using form customization, then those fields are no longer usuable for bulk edit. This functionality is by design because CRM cannot execute your JS code for each record during a bulk update. In my situation however, I don't care; I still wanted both the customization and bulk edit.

My solution is to override the OnChange events without using the form customization UI. When my form loads, I import & execute a stand-alone JS file (in the forms OnLoad event) that contains functions that define OnChange events for fields. for example:

crmForm.all.new_investor.OnChange = function(){
alert("got here");
}

This code will execute when I change the investor field, but will not prevent the bulk edit from working.

No comments: