简体   繁体   中英

How to debug jScript for Dynamics CRM?

Are there any tricks or tools for debugging those jScripts that you write in the web resources and attach to an event on a form ?
I have to customize a Dynamics CRM 2011 instance, which includes writing some jScripts.
The best I found until now is to click "I want to see the error that's being sent to Microsoft". Better than nothing, but I guess there must be something better ?
Thanks!

If you use a decent version of IE (I hope you do), you could use the developer tools (F12). They also contain a JavaScript console/debugger which got really usable in the meantime.

You have to select the file which should be inspected, set a breakpoint and start debugging.

See this article for an example: http://www.furnemont.eu/2010/06/how-to-series-easily-debug-your-crm-javascript-code-in-ie8

For development of form scripts use the Xrm.Page Script Library Template described in the SDK topic Write Code for Microsoft Dynamics CRM Forms . The CRM team blog post JScript IntelliSense for Form Script Libraries provides an overview.

When you use this template, in addition to providing form specific IntelliSense, you can debug your scripts in Visual studio without uploading them as Web resources. This makes initial development and debugging easier.

After you have it working, then create a JScript web resource and register it as a form event handler and test it in the application. At that point, use the technique described in the How-to series: Easily debug your CRM JavaScript code in IE8 (link in other answer) to debug your script using the IE developer tools.

The advantage of debugging your scripts outside of Microsoft CRM is simply that it is simpler. CRM loads many different scripts into the forms that it is sometimes tricky to isolate just your script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM