Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Dynamics 365 Debugging Tips

Post Author: Joe D365 |

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:

  1. Breakpoint Window
  2. Conditional Breakpoints
  3. Pin Data Tips
  4. Out-of-Scope Objects
  5. View Return Values for Functions

Let’s look at each in detail…

1. Breakpoint Window

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.

debugging

 

2. Conditional Breakpoints

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.

debugging

 

3. Pin Data Tips

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.

debugging

 

4. Out-of-Scope Objects

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:

  • Set a breakpoint near a variable that you want to track.
  • Stop the breakpoint at your variable.
  • Find variable in the Locals window (Debug > Windows > Locals), right-click the variable, and select Make Object ID.

debugging

 

  • Right-click the Object ID variable and choose Add Watch:

debugging

 

5. View Return Values for Functions

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:

debugging

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.

Happy debugging!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends