02/01/2013

Debugging JScript in Microsoft CRM Dynamics 2011

How to debug your JavaScript

The following include steps we should follow to prepare IE to debug JScripts in a CRM dynamics forms:

Enabling the Every Visit to the Page Feature

  1. Start Internet Explorer. 
  2. Select Tools, and then Internet Options. 
  3. On the General tab in the Browsing history section, click Settings. 
  4. Enable the Every time I visit the webpage option. 
  5. Click OK. 

Setting Script Debugging and Friendly Errors Options

  1. Start Internet Explorer. 
  2. On the Tools menu, click Internet Options. 
  3. Click the Advanced tab. 
  4. Clear the Disable script debugging (Internet Explorer) option. 
  5. Clear the Show friendly HTTP error messages option. 
  6. Click OK.

Debugging

Now simply add debugger; Jscript command in your Jscript from event.

Sample:
 
if (typeof (Account) == "undifined") {Account = {};}

//*****************************//
/* Main Account From Namespace */
//****************************//
Account.DefaultForm =
{
    CREATE_FORM_TYPE : 1,

    //*********** on Load **************//
    OnLoad: function()
    {
        debugger;
        Alert('OnLoad function of the Account Default form starts here');

    },
    //*********************************//
};
Publish your webresource and refresh the browser.
When you trigger the webresource (e.g. loading account form in the above sample code) the browser will show you a dialog box where you can debug your code in visual studio.

No comments:

Post a Comment