Saturday, February 2, 2013

Fiddler, CRM and Javascript Time Saver

UPDATE: Microsoft has changed the way they send the JavaScript to the browser (See here for more info) so this tip will only work up until Rollup 11.

To get some real productivity gains when working with Javascript and CRM you can introduce Fiddler into the mix.  Fiddler has a feature called 'Auto Responder' which allows you intercept a file requested by a browser from a web server and replace it with a different file of your choice. 

By using this feature, it means that you don't have to go through the somewhat annoying process of modifying a Javascript file, deploying it and publishing it before you can test the changes; instead you can simply modify a Javascript file directly on your hard drive and then simply refresh the CRM form to test your changes.  You only need to deploy and publish the change once you are happy with the modifications and want to commit them to CRM.

Here's how to set it up:

1. Install Fiddler on your local machine
- you can download it from here for free:

2. Choose an already published web resource file from CRM (e.g. new_js_accounts)

3. Open up fiddler and click on the "Auto Responder" Tab

4. Tick the "Enable Automatic Responses", then tick "Unmatches requests passthrough" (very important!)

5. Click the add button and add a new rule, setting the first Rule box to the name of your web resource name (as highlighted on the URL in the first image above), and use the second box to "Find a file...", choosing the file which you want to replace the web resource with from your local machine.  It should look something like this:

Once this is done, you should find that whenever you refresh your CRM Form now on it should point to the local copy of the file and ignore the server one.  In Fiddler you can also turn this on/off by using the tick box next to the rule at any time.

Don't forget to still upload and publish to CRM after you are done!