If you were not aware of it yet, one cool feature of CRM 2011 is the ability to add the same field more than once to a form. It comes in handy when a customer uses the same form but the form changes based on form condition, say a selected product. It is easer to create two sections and the same field to the two sections and then toggle the two section on/off based on the product selected.
Example of CRM 2011 form with two section having similar fields
While transparent to the user, when data is entered a field that is duplicated on the form MS actually displays the same value in all the fields.
Example of entering value in one textbox is displayed in the other
Our problem came when we wanted to add JavaScript validation onto those fields using using the DOM. While it makes sense, it caught us off guard because MS actually assigns a different DOM ID values to each duplicated field. Code used to access a single field on the form that is not duplicated on the form is different from fields that are duplicated.
Example Code Single field on form
- document.getElementById("mlo_bin").attachEvent('onblur', checkForNumeric);
Example Code for Form with same field multiple times
The ID of the field on the form gets a integer value added to the ID. You can see in this example if you have the same field three times.
- document.getElementById("mlo_bin").attachEvent('onblur', checkForNumeric);
- document.getElementById("mlo_bin1").attachEvent('onblur', checkForNumeric);
- document.getElementById("mlo_bin2").attachEvent('onblur', checkForNumeric);
Hope it helps!
Post by: Sean Shilling,