OnChange Event

When starting to work with CRM, one of the first things you learn is how to put some script on the onChange event. It’s easy to do this and it really works.
Let’s say you want to fire that script at the first moment your page is loaded.
In CRM 3.0 you could do that writing a single line :
When starting to work with CRM 4.0 I tried to use the same code but it didn’t work anymore. I was sooooo disappointed and I hardly found out the solution. That’s why i thought of sharing it with you.
The code for firing a script put on the onchange event for CRM 4.0 is:

I hope this helps. Happy coding! 🙂


  1. Hi All,

    The CRM JavaScript FireOnChange() method does not fire when the Crm record is opened in ReadOnly or Disabled mode.
    Further the FireOnChange() method will fire when changed to onchange0() in case of readonly mode or disabled mode .
    This will also not work when the field on Crm Form is in locked mode
    i.e. as an example the customer field on the Case Form.
    For this field the FireOnChange() or onchange0() method will not get called when the record is opened as in readonly or disabled mode.

    I guess this is a bug with MS Crm 4.0..

    Pls let me know if any one has some solutions or workaround for this one.


  2. Personally, I don’t use the OnChange section to write code for this event for a certain field… Instead I use the OnLoad() event and I attach an “onchange” event to the field of my interest…
    for example:

    function SayLol() {

    should work in readonly state as well… full control 🙂

  3. Hi,

    Yes that is correct.. That is an option which I can look forward to implement
    But my main concern here is that I have 1000s of line of code already there in my OnLoad event.
    To add to that if I take out all the OnChange Event scripts and add that too on the On Load event.. It is really gonna get too long and even more difficult to debug.

    So that is one of tjhe reasons I have put the onchange event scripts differently on the “onchange” event editor rather than page load.

    But I guess since this problem persists, may be there is a bug in CRM 4.0.

    Thanks In Advance

  4. Hi,

    As I see no other way out I will be writing all code in onload event…
    Thanks anyways….
    No other solution 🙁

    Have a great and Happy New Year….


  5. We found a great way to move all of our OnChange scripts into OnLoad… using the JavaScript Factory from http://www.stunnware.com.

    It's a great tool to help you manage your CRM scripts and will save you weeks of recoding. It's even worth the few Euros to manage the code if you don't need to migrate OnChange.

Leave a comment

Your email address will not be published. Required fields are marked *