locked
Should a disabled field trigger an onchange event? RRS feed

  • Question

  • If a field is disabled, but is set with script (or pre-operational plugins), should the field onchange script fire? It appears to be firing in CRM 2013, and it seems to me like that is incorrect.
    Thursday, May 1, 2014 5:49 PM

Answers

  • Hi,

    In CRM 2013 on change evet will trigger even though the field is disabled or enabled whenever the field value will change.

    Even on change event will trigger if you are setting the field value from plugin and it will also trigger when the form is saving.

    For details see the below link:

    http://crmtipoftheday.com/2014/03/14/simulate-onload-event-for-form-updates/

    Regards,

    Priya


    • Proposed as answer by PriyaSwain Monday, May 5, 2014 6:31 AM
    • Marked as answer by KTurbyfill Monday, May 5, 2014 12:03 PM
    Monday, May 5, 2014 6:30 AM

All replies

  • I did something similar. In a form, I was setting value for a field using pre-operation plugin on retrieve message. This value gets set on the form. But events won't fire on the field as it was disabled. So I had to enable, fire event, and disable that field using JavaScript.
    Thursday, May 1, 2014 9:54 PM
  • OnChange event on any UI control will only triggered when values are changed manually on CRM Form UI. In your case values are set at server side via Pre-Operation plugin, and it is rendered on form. So technically there should not be any onchange event fired irrespective of whether the field is enable or disable.

    Thanks

    Mak


    MaKeer | myencounterwithcrm.wordpress.com | CRM2011 User Settings Utility | CRM2011 Lookup Preview | CRM2011 Lookup Attribute Mapping | CRM2011 TreeView Control (Beta) | CRM2011 N:N Entity View (Beta) | CRM 2011 Global Quick Search (Beta)

    Friday, May 2, 2014 12:03 AM
  • Hmm, well that's not what I'm seeing in CRM 2013. I am setting the scheduled start and end dates with a pre-operational plugin, and when the form renders, it displays error messages that are coming from CRM's onchange handlers. In CRM 2011 everything worked fine.
    Friday, May 2, 2014 11:58 AM
  • Place a debugger in the JS and see whats the actual error.
    Friday, May 2, 2014 3:30 PM
  • Hi,

    In CRM 2013 on change evet will trigger even though the field is disabled or enabled whenever the field value will change.

    Even on change event will trigger if you are setting the field value from plugin and it will also trigger when the form is saving.

    For details see the below link:

    http://crmtipoftheday.com/2014/03/14/simulate-onload-event-for-form-updates/

    Regards,

    Priya


    • Proposed as answer by PriyaSwain Monday, May 5, 2014 6:31 AM
    • Marked as answer by KTurbyfill Monday, May 5, 2014 12:03 PM
    Monday, May 5, 2014 6:30 AM
  • Thanks. That is unfortunate as it is CRM code that has the onchange handler that is breaking because I set those fields in a plugin.
    Monday, May 5, 2014 12:04 PM