Sunday 24 February 2013

Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online - Benefits of having the JScript Web Resource Code as a separate JS file

When I create a new JScript web resource, there are 2 ways to add code to it. 

One way is to upload the JScript file to the web resource. This will embed the "JScript file" code inside the web resource.  


 Below is the file in Visual Studio and uploaded as part of a web resource.

JS File in Visual Studio 2010


JScript File uploaded as part of a Web Resource

The other way to create an empty JScript web resource. Later open the JScript web resource and add the code through its text editor.


Web Resource Text Editor
JScript in Web Resource Text Editor
In existing JScript web resources there are 2 ways of making changes to the code. Either you make changes to the code in a corresponding file (if it exists) and then copy paste this code back into the web resource. OR you can open the web resource text editor and make changes.

The best practice is to have a separate JS file for every JScript web resource. This JS file should contain the same code as its corresponding web resource. The main benefit is that these files can be version/source controlled. 

Microsoft Dynamics CRM is not a version/source control application and hence the code inside the web resources cannot be version/source controlled. It is better to have the JS files and have these files version controlled. 

There are many version control software available. My favourite is TFS (team Foundation Server). Team Foundation Server (TFS) is a Microsoft product offering source control, data collection, reporting, and project tracking, and is intended for collaborative software development projects.

If you need to make changes to any web resources, first update the code in the corresponding JS file and then make these same changes inside the web resource. The other way is to make changes in the web resource and test these changes and at the end update the corresponding JS file in the source control.

I hope this blog about 'Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online - Benefits of having the JScript Web Resource Code as a separate JS file' was informative. Please feel free to leave your comments.

2 comments: