Dynamically Loading Scripts Files on Dynamics CRM

People who are working in customizing Dynamics CRM system should all sooner or later facing this problem: what can I do to have my common sharing Javascript library injected in an elegant way so that all the events in all my crmForm can use it without problems?

As now I am engaging in a Dynamics CRM customization project and am building a common base framework for CRM developing of our vendors, I am also facing this problem. (also others though...)

In David Yack's book "CRM as a Rapid Development Platform", he is using an OO Javascript writing of base classes to be used in crmForm, and to overcome the offline CRM client problem, paste all the base class code in every entities' form's OnLoad event. the idea of writing Javascript code in VS2008 and utilizing intellisence support are pretty good ideas also.

Michael Höhne from Stunnware.com is using another approach to dynamically load javascript files of common sharing client code to the crmForm. Refer to his excellent articles here and here.  Although it's modifying the form.css file to add extended logics, which becomes an unsupported custimization. he minimized the impacts of the side effects so that it can be easily recovered after a hotfix patch or version up of CRM system. notice that this approach may not work in CRM offline environment and may need further works to deploy your javascript codes into client machines.

if your solution will only target in online environment, like mine this time, I think Michael's solution will be a good one to implement. base on what you need, choose the proper solution to make your solution work.


Technorati Tags: microsoft,dynamics,crm,javascript