Quick Tip: Debugging Dynamics 365 JavaScript

So, you’ve got a JavaScript you’re having trouble with. What you can do is fire up Chrome, open the Developer Tools by pressing F12, choose the Console tab, and then log into your D365 instance.

Errors in your JavaScript should show up on the Console. You can also embed alert() calls in your script to show you values of variables and other statuses.

A really cool trick is to change the target to the content frame, giving you access to all the good CRM stuff:

Now, you can type things in the Console like:

Xrm.Page.getControl("ckc_eventsecretary").setVisible(false);

and that field will instantly get hidden! Very cool. There is Intellisense there so you can navigate all the different functions like getValue, setValue, setDefault, etc. You can use this to fiddle with the code until you get it fixed – then you can update your JavaScript and continue.