Dynamics 365 v9.0: No More Hidden Fields

Hello everyone,

As a developer, we come across many situations where we keep a hidden field on the form only for the purpose of data manipulations. This approach always worked. However, it was difficult to keep track of what hidden fields are required on the form and by which java script web resource.

This poses two issues:

1. Sometimes we may end up accidentally removing hidden fields from forms

2. It will be a time consuming task to come up with the list of hidden fields to add on a form if we plan to reuse a web resource which uses hidden fields.

With Dynamics 365 9.0, we can avoid these situations with “Attribute Dependencies for JavaScript Web Resources”. Here is what we have to do to accomplish this. Under “Dependencies” tab of the web resource(only JScript), add attributes(so called hidden fields) to the second grid. All the attributes added in this grid are no longer required to be present on the form. When the web resource loaded on the entity form, it makes sure the dependent attributes are automatically added to the attribute collection on to the form. This allows the JScript web resource to do data manipulations without adding hidden fields to the form. One thing to note here is, these dependent attributes are only added to the attributes collection and not to the controls collection which means we cannot use “data.ui” related methods.

EntityAttList

AttList

Observations:

  1. Attribute Dependencies are only available for JScript web resources.
  2. Dependent attributes are added only to the form attribute collection. So, only attribute methods can be used.
  3. Attributes can be added from multiple entities. This is useful for the web resources reused across multiple entities.
  4. Once dependent attributes are added to attributes collection on the form, any web resource(JScript and HTML) on the form and Business Rules can use those fields for data manipulations.

Hope it helps..!!

Leave a Reply

Your email address will not be published. Required fields are marked *