-
Disabling all fields within a Section
Last week I encountered a need to disable all of the fields within a Section on a CRM Form. While you can set the properties individually, that is a waste of effort and a maintenance nightmare.
After a bit of digging, I found the following post on one of the CRM newsgroups by Kyaw Kyaw Tun, from http://www.pulsesync.com:
var section = crmForm.all.new_attribute_c.parentElement.parentElement.parentElement; for (i = 0; i < section.all.length; i++) { section.all[i].Disabled = true; }
You replace new_attribute with the name of an attribute that resides inside the section you wish to disable.
Note: That _c is not a mistake, that needs to be part of the attribute name. For instance, to hide the section containing accountnumber, you would use accountnumber_c.
Though the magic of the JavaScript Document Object Model ( DOM ), we’ll get a list of all of the fields and set their Disabled property to true.
Customization, Dynamics CRM 449 views2 responses to “Disabling all fields within a Section”
-
Simple, but effective, thanks for sharing.
-
For added info: That _c refers specifically to the label of the field, as an element on the page; _d would refer to the actual field containing the data.
These can also be used for other tweaks such as colour changes etc. and the parentElement… method can be used to hide / show an entire section, or even an entire tab (which you could also do with tab number if you can rely on the order of them never being changed)(I remember them as c for "caption" and d for "data" but I have no idea if this is the 'official' reason for these abbreviations. Anyone?)
Leave a reply
-



