718 Washington Ave. N. Suite #101
Minneapolis, MN 55401
View map and all Locations

Send us a message

I recently encountered some difficulty  firing a JavaScript event off when a bit field was marked as True. The following code worked fine when the bit field was a radio button on the form, but the event would not fire until I tabbed out of the field when I had the bit field formatted as a checkbox. This was in my onChange() event for the bit field.
hideField = function() {


if (crmForm.all.some_bit_field.DataValue == 1)
//Hide Some Fields

It came to my attention that checkbox-type bit fields are handled a bit differently in Dynamics CRM. The onChange () event for a checkbox will not be fired until we leave the field. This was a problem as the customer expected the field to show/hide immediately when the field was changed, not when we tabbed off the field.

To solve the problem we simply added some Event Handling code into the onLoad event area of our entity form. With this piece of code included, the field will show/hide as soon as the value changes, not when we tab off the field.

crmForm.all.your_checkboxfield.onclick = function() {

Using the code above, the onChange () event will fire TWICE: Once when the field is changed and once when we tab off the field. If this is a concern in your implementation you can use the following code in the onLoad() event to ensure the event only fires once (Remember to remove the code from the fields’ onChange event is you use the code this way!)

crmForm.all.your_checkboxfield.onclick = function() {
    //Existing onChange() code

Happy Coding!

Avatar for Joe D365

Joe D365

Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.