Custom Web resources – “X” is not a function


One of my custom developed webpages was not loading properly in Dynamics CRM V9, to my surprise it was working perfectly in Dynamics CRM V8. The error thrown in the browser console revealed the following error: “x” is not a function.

After I discovered that the functionality was working as expected in a V8 version of CRM, I could start to debug the web resource and find out what the difference was between the 2 versions of CRM.

In the debugging process I started to monitor the network and which files where loaded to check if everything was loaded as expected. It was at this moment that I noticed a difference. In the custom web resource, I was including ClientGlobalContext.js.aspx to be able to access the global context.

In V9 the ClientGlobalContext.js.aspx is loading more files compared to V8.


Figure 1ClientGlobalContext V9 loaded files


Figure 2ClientGlobalContext V8 loaded files

Notice in the V9 the jquery-2.1.1.min.js that is not loaded in V8. The loading of this file was causing my error. In my custom web resource there was also a reference to the jQuery library, but a later version. In the web resource I first included jQuery and afterwards ClientGlobalContext.js.aspx.


Figure 3 Order of loading

Because ClientGlobalContext was also loading jQuery but an earlier version than the required version we got the error mentioned above: “x” is not a function”. Changing the order in which the files were loaded resolved the error.


If your custom web resource requires a certain version of jQuery, make sure this version is the last one loaded on the page. Hereby don’t forget that including ClientGlobalContext.js.aspx is also loading JavaScript files.