Hide And Show a Field in Dynamics 365 CRM Using JavaScript


In Dynamics 365, you can hide and show fields using JavaScript. This is useful if you have business logic that determines if fields are displayed or not to the user.


Let’s take an example where you would like to hide the Account field if the Contact field is populated.

Next, we can check if the Contact field is empty using getAttribute(“fieldname”).getValue(). If empty, we can hide the field using setVisible. Let’s add this to the change event of the Contact field:

function showAccountOnChange(executionContext)
formContext = executionContext.getFormContext();

if (formContext.getAttribute("parentcontactid").getValue() == null)


When Contact field is populated, the Account field is displayed:

When empty, the Account field is hidden and the field collapses (note this is v9 Dynamics 365):

Hope this helps …

Share Story :

Secured By miniOrange