Are you still including unnecessary fields on your Dynamics 365 forms so that your scripts can access it? May be it’s time to use Attribute dependency feature of webresources.

Sometimes we are so much busy in our day to day consulting stuffs that we frequently miss those small little gems in Dynamics 365 which are scattered throughout but we tend to ignore them more often than not.

And one of them is the Attribute dependency feature in webresources.


How many of you faced a situation where you needed to just put an attribute on the form so that the code inside your form events and field events can access the field to get its value and take logical decisions depending on the field value? And attribute dependencies just helps you to get around it. But trust me, still in 95% of the cases where a requirement like this arises, we go ahead and put the field on the form and hide it so that our scripts can access it. Now that you understand, let’s see how it is done.

We will use account entity attribute “industrycode” of type optionset as dependent attribute to the web resource which is being referred in the form load of account entity.

Create a web resource and go to Dependencies tab. Click Add to choose your entity and fields


Select Account entity and choose your dependent fields from the available fields


Now save and publish the web resource. I have added the lookup field, parentaccountid as well as dependency


Note: Make sure you save & publish your web resource to establish the configured dependencies. It’s very important to first click on Save and then publish to reflect the changes.

Open the Account entity form make sure the “Industry” field is not there on the form. All our customizations are in place and let’s see what magic we can see now

Open any existing account record. I will use Developer Tools window to test this.

P.S – I am using the deprecated Xrm.Page here since I am demoing it in developer tools window. For real scenarios, use the formContext to access your controls and attributes.

Let us now verify whether the industry control is available on the form. To do that just type this command “Xrm.Page.getControl(“industrycode”)”.


The control is unavailable which makes sense but the great thing is that we can still get the value of the industry field. To get the value of field just type following commands


Value : Xrm.Page.getAttribute(“industrycode”).getValue()

Text: Xrm.Page.getAttribute(“industrycode”).getText()


Not only this, you can even set the value and save the record.

In this way we can set value of fields which are not placed on the form. And also use their value to arrive at business decisions. Before this feature we would need to add the field on the form and hide the control. The dependent attributes are not limited to single entity, we can even select attributes from multiple entities and attach to web resource and the same webresource can be used in multiple entity form and field events.


So unless you need to work with the control, use Attribute dependency and don’t unnecessarily drag and drop the controls on the form and increase the form clutter.

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit or reach out to us at

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (

Notes Manager (

Role based views for Dynamics 365 (

Record Cloner for Dynamics 365 (

Published by


I am a Dynamics CRM Most Valuable Professional (MVP) with 12 years of experience in Microsoft .NET Technologies and 9 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under For consulting/ training, drop me a note at or visit our website

2 thoughts on “Are you still including unnecessary fields on your Dynamics 365 forms so that your scripts can access it? May be it’s time to use Attribute dependency feature of webresources.”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s