Here is something that does not come up often.. When you have a few controls for the same attribute added to the form, using Xrm.Page.getControl(“<name>”).setDisabled won’t enable/disable all of them – it will only work for the first control on the form. At least in the 8.2 version.
If you wanted to do the same for all such controls, you might need a function like this:
function setDisabledAllControls(attribName, value)
{
var attr = Xrm.Page.getAttribute(attribName);
attr.controls.forEach(function(control) {
control.setDisabled(value);
});
}
PS. You might be asking why would anybody have more than one control for the same attribute added to the form. Well, first of all, Dynamics does not stop us from doing this, so what’s not prohibited is allowed.. and, therefore, will happen every now and then. As for the reasons, it might be more of a a user-experience feature – when there is a long form, and you need users to be aware of some particular attribute, you might want to put it in different tabs/sections on the form.