A user asked if it would be possible to recreate cascading drop down lists like they had in SalesForce. I thought this would be an out of the box configuration and agreed that they could have it. Surprisingly, this doesn’t seem to be something that is out of the box – but handily Microsoft have published an excellent tutorial on MSDN about how to do this using JavaScript.

The tutorial by Microsoft is very useful, but I wanted to create one in my own words with a few more images to hopefully help newer members of the Dynamics community. I’ve not included the code in this blog in case Microsoft update the MSDN article with newer versions of the code.

In this example, I will be making a cascading drop down between the out of the box businesstypecode field and a new custom field called new_businessspecialisation. 

JSON

The code Microsoft provided uses JSON to manage the parent child relationships, this works well & is easy to create, but might become time consuming if the field values change regularly. It may be worth investigating whether there is another way to do this that provides the user with a front end to manage the relationships, but that was beyond the scope of this work.

Setup

The JSON file will need to be uploaded as a web resource (of type JScript). The code provided by Microsoft will also need to be uploaded as a web resource. 
Cascading Drop Down - web resources
Adding the code as web resources

Once the web resources have been created you will need to define the Form On Load functionality, to this simply add the library, enter the function name and pass in the name of your JSON file into the parameters. The script provided by Microsoft this will then concatenate this into a URL to load the source from.

Setting the On Load Event
Setting the Form On Load event
Once the Form On Load event has been created you will then need to create the On Change event for the parent field. This time you will need to pass in the name of the parent field & the name of the child field. In the Microsoft example they do this another as they have an extra level.
Setting the field On Change event

Once this has been done, everything should be good to go. The next couple of images show the functionality in action.

Field locked because no parent Business Type has been chosen
Metal & Plastics showing for Manufacturing
Dynamics & SharePoint showing for Application Development

Summary

Overall, thanks to the Microsoft sample code this proves to be a relatively simple piece of functionality to add that potentially provides a lot of value to the end user. I’m hopeful that this will be added into the system at some point.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu
%d bloggers like this: