CRM 2016 – SetDisabled is not working – XrmMtl Skip to content

CRM 2016 – SetDisabled is not working

Hi folks,

Today, I found  a new bug in CRM.


I have a form with two sections. Under some circumstances, I show one and hide the other. That part is working.  In both of those sections, I have a field called xrm_field. Again, under some circumstances, I want to disable that field doing the followning:

[code lang=”js”]Xrm.Page.getControl(‘xrm_field’).setDisabled(true);[/code]

While testing my code, I discovered that when the second section is hidden, the field is disabled, but when the first section is hidden, the same field is not. Therefore, I made sure that nowhere in my code I was enabling/disabling it again.

Résultats de recherche d'images pour « meme question mark »

The problem

To understand why this is happening, I dug into MSCRM javascript. What I found out made me shudder. In a list of all the controls, I saw this:

  • xrm_field
  • xrm_field1

So I added:

[code lang=”js”]Xrm.Page.getControl(‘xrm_field1’).setDisabled(true);[/code]

and it worked!


Against all odds, the MVC pattern that is working with the attributes, is not with the controls.

So, until this is fixed, we’ll have to remember to set the “other” control too.

Hope this helps!

Published inUncategorized