Developer 101: speed up Javascript development

Writing Javascript within CRM can be a tedious task. The script editor Dynamics CRM is offering is nothing more than a multi line textbox with tiny characters. No color coding, syntax highlighting and other things that can make your life so great.

Most developers avoid the Dynamics CRM script editor like the plague, and seek their resort in fancy editors like WebStorm, Visual Studio or Notepad++. All code is written in the external editor and finally uploaded to CRM. Where it has to be saved and published. A time consuming and boring process…

In case you made a typo or want to do a small adjustment, the code has to be uploaded to CRM, get saved and published….  and so on, and so on…

Bored

At the moment I’m doing some client side development for the project I’m working on. Triggered by a ribbon button, I have to pop up a small dialog in which I can ask the user for additional information. Based on data he enters a follow up process is triggered.

After a couple of cycles of code uploading, saving and publishing I got fed up with it, I wanted to find out if there was any way to speed up the process and keep me happy. Fortunatly I stumbled on a CRM 2011 blog article written by Nizar JLASLI in which was described how to set up Fiddler to help you with development.

In this article I want to give you an update to that particular article, intended for Dynamics CRM 2015 and Fiddler 4.

Fiddler 4

Fiddler is a free web debugging tool from Telerik that can be used to manipulate and edit web sessions. One of the things you can do is alter the request and response. This enables you to redirect calls to webresources in Dynamics CRM to webresources locally on your file system. All within the context of Dynamics CRM.

Redirecting responses to local webresources will help you to do all editing locally. Giving you the opportunity to modify your webpages and scripts on the fly. By doing the modification locally, save it locally and hit the refresh button in your browser. This helps you to hook up the debugger in your browser (e.g. firebug or IE developer tools).

Fiddler

 

Setting up fiddler

Once Fiddler is started, we see two important tabs:

  • AutoResponder
    This tab allows us to intercept a request and give an alternate response
  • Filters
    This tab allows us to do specif filtering, as we don’t want to intercept all traffic.

First we select the Filters tab. In this tab we narrow down the hosts which traffic we will intercept. In this case I chose to capture all traffic from “*.crmpartners.dev” , In the Request headers section I narrowed down the URL path I want to intercept. In this case “WebResources”.  By setting the filters the amount of traffic visible in Fiddler is reduced to a minimum.

Fiddler0

Time to start capturing traffic. This can be done by pressing F12 or by selecting the option Capture Traffic in the File Menu.

Fiddler1

Once the capturing is started, we can navigate our browser to load the page in CRM. The left pane is filled with all requests. We can select a line and drag it the the AutoResponder tab. A new Exact match appears at the bottom of the list.

Fiddler2

In the AutoResponder tab make sure the following check boxes are marked:

  • Enable Automatic Responses
  • Unmatched requests passthrough

Finaly we can modfy the rule we added.

The rule in the tab says: if the requested URL is exact like the URL in the autoresponder list, then respond with the following action.

Fiddler3

By clicking the dropdown with “*200–SESSION_25” we get the opportunity to select our local web resource. Instead of exact matches “EXACT:” we also can use regular expressions “REGEX:” to make the URL matching more flexible (this is required when working with query string parameters.)

Fiddler4

Each time we call the specific webresource, Fiddler will intercept the call and respond with the local resource. This will speed up your development. What you should keep in mind is that all changes you do are on the local file system only. Once you completed your development effort, you will have to upload the webresources to CRM.

Leave a Reply

Your email address will not be published. Required fields are marked *