Dynamics 365 V9 JavaScript Web Resource Dependencies

Jared Johnson, 05 February 2018

Prior to the V9 update to Microsoft Dynamics 365, if a JavaScript Web Resource was dependent on another, both had to be added to the forms scripts or on a ribbon button command in the correct order.  Forgetting to add a required JavaScript library to the form was one of the most common errors for JavaScript in CRM, not to mention the issues caused from the parallel loading of scripts on the form from UR12 onwards.

However, in V9 you can now specify what JavaScript resources are required from the Dependencies tab on the Web Resource.

image

In this example I have added the Alert.js library as a dependency. This means that Alert.js will be automatically loaded when this Web Resource is added to the form scripts. It will also be loaded for Ribbon commands and enable rules, removing the need to create dummy IsNaN functions.

In addition, this will act like other dependencies in CRM, not allowing Web Resources to be deleted if they are required by other Web Resources, and showing as a missing component if missing from a solution.

image