Monday, October 15, 2007

How to Include JS files in CRM 3.0

I encountered a problem while customizing a CRM 3.0 implementation for a client.
The problem was that the project required a lot of JavaScript and if you have been working with CRM 3.0 you already knows how frustrating it is to develop using JS within crm.

In order to remedy that problem, I thought of using a custom .JS file and include it in the forms that I was customizing. Microsoft clearly states modifying the CRM source pages is not supported or recommended and may not survive an upgrade or a patch.

Here is my solution that may help us all in future CRM 3.0 client side development.

Create your .JS file.

Place it either in a new Virtual Directory within the CRM website or as a separate website all together.

Select the entity that you want to customize and enable the OnLoad event.

Put the following code within the event:

var script = document.createElement("script");
script.type = "text/javascript";
script.src= "[the location of your script either relative or absolute]";

At this point the .JS file has been appended to the page and has been subsequently loaded by the browser.

***Please note that any modifications to the JS file will require you to clear the browsers Temporary files, otherwise it will not load the latest version. ***

*** this has not been tested for CRM within outlook. ***

Have a great day.

Oshri Cohen

Labels: , , , , ,


Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home