Prior to the Wave 1 2020 release, the allocation of charges capability was available only on the Purchasing side of F&O processes. In this blog, we’ll review the Current State process and share some exciting news about Future State process.
In today’s blog, we’re sharing some helpful hints for debugging Dynamics 365 code in Microsoft Visual Studio. The transition from the old MorphX debugger to the Visual Studio debugger brought many new features that can significantly assist with the debugging process. While attempting to document these new features, we began noticing (and thus compiled) a handful of helpful tips that we’ve come across while using Visual Studio to debug D365 code. They are:
Let’s look at each in detail…
When working your way deeper into some complex code through several different objects, you inevitably end up with one or two breakpoints that are continuously getting hit. If you remove the breakpoint, you’ll have to come back and find it again, which is a hassle. So, instead of simply removing the breakpoint, try using the Breakpoints window, as shown below. This window will show all breakpoints you have set, but – and this is crucial – lets you disable them without unsetting them by simply removing the checkmark. To re-enable a breakpoint, simply check it again.
It is often difficult or time-consuming to recreate a specific state for your current debugging session. Therefore, it is worth considering whether the use of conditional breakpoints can help. Right-click any breakpoint icon (the red balls) and choose Conditions from the menu. In the Breakpoint Settings window, you can choose to create a conditional expression in which the breakpoint will cause execution to stop only if the condition is true. You may also choose Hit count, where a breakpoint interrupts execution after a specified number of hits. Another available option is to create an action that logs a message to the output window.
When debugging code, it’s helpful to be able to hover over a specific variable to see its current value. Even more helpful is to pin the data tip for the variable to give yourself quick access to its value. To pin the data tip, click the pin icon (thumbtack) while hovering over it. This will then automatically display the value without the need to hover over the variable. You can pin multiple variables.
When a variable goes out of scope in the Watch window, you may notice that it is then greyed out. You can track those out-of-scope variables by creating an Object ID for them in the Watch window. Here’s how:
In order to view return values for your functions, look at the functions that appear in the Autos window to see the return value for each function and make sure the function you are interested in has already executed:
Hopefully these tips and tricks are as helpful for you as they have been for us. They certainly can make debugging D365 code in Visual Studio a little bit easier. Don't forget to subscribe to our blog for more tips and tricks.