Debugging JavaScript code in MS CRM 4.0

It was real tough not knowing how to debug JavaScript Code in MS CRM 4.0. Every time I had to publish the forms and test with Alert Messages. It really got on my nerves and thought I better find a way out of this and that is when Stunnware helped me. I wanted to share the learning with you and here it is…
Open the Internet Explorer settings and select the Advanced tab. In the list of available options find the “Disable Script Debugging (Internet Explorer)” setting and make sure it’s unchecked.
Open any script you want to debug and place the following just before the statement where you want to start your debugging session:

debugger

That’s all, no semicolon, nothing else. To test it, run your form from the designer (preview mode) or publish it first. Once the script engine reaches the debugger statement, a list with all available debuggers is presented to you, including the Microsoft Script Debugger, Visual Studio 2003, Visual Studio 2005 or whatever is registered as a script debugger on your machine. You should try all debuggers to find the one you’re most comfortable with and mark it as the default.
Like any other statement, you can simply comment out the debugger statement, so

//debugger

will actually turn off debugging.

All users that have not unchecked the “Disable debugging” setting in IE will not be prompted to start a debugger. However, you should make sure that you remove these statements before publishing them to a production environment. The easiest way to ensure it is to export all customizations and search the export xml file for “debugger”.

For more information about the debugger statement, see this link.

Happy Debugging JavaScript Code in MS CRM 4.0 !!!

Leave a Reply

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