web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Hide And Show a Field in Dynamics 365 CRM Using JavaScript

Community Member Profile Picture Community Member

Introduction:

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.

Implementation:

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)
{
formContext.getControl("parentaccountid").setVisible(false);

}
else
{
formContext.getControl("parentaccountid").setVisible(true);
}
}

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 …

The post Hide And Show a Field in Dynamics 365 CRM Using JavaScript appeared first on .

Comments

*This post is locked for comments