A Special Way of Debugging

Every developer needs to debug every now and then.
But it becomes a challenge when you didn’t wrote every line of code.

Maybe an addon will case the problem.
Default NAV or a CU update can also be the reason.
Or the combination of these.

So where do you begin? First you start debugging and break just before you press the function that causes the problem.
Then you follow every line of code in the debugger. Jump from one codeunit to another. Very time consuming.

For example I need to know why the system creates 2 warehouse entries when I post a sales order. First I started debugging the normal way. But as you know posting a sales order will go through codeunit 80 and that is a long one with a lot of side jumps to other codeunits.

So I though there must be a faster way.
And what do you expect I found one ?

First I have created a codeunit that subscribes to the OnBeforeInsertEvent of the Warehouse Entry table.

In my new function I set a breakpoint and start debugging again.
As you can see the debugger stops at my breakpoint.

And if you look to the Call Stack you will see that a new Warehouse Entry is created from Codeunit 7301 for example.

Because you now have the full Call Stack you can navigate back instead of following every line of code from the start.

This has won me a lot of time and I hope you will too in the future.

2 thoughts on “A Special Way of Debugging

Leave a Reply

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