Fun with the Dynamics NAV Debugger
Recently I had to debug some custom code I added in Dynamics NAV. Some object was throwing an error because of an overflow converting Text 60 to Text 30. Because in the code were the error occurred, many other objects were called, it was not so easy to see were the error originated from. But then I noticed a nice feature of the Dynamics NAV debugger that pointed me in the correct direction.
Let's make an example. Codeunit 365 is frequently used to format addresses when running reports. Let's say that when running a Sales Invoice something goes wrong when calling the FormatAddr function.
For example, someone has changed the table design of the Sales Invoice table and enlarged the 'Bill To Customer Name' from 50 to 100 characters. The FormatAddr function expects a parameter Name that can be maximum 90 characters in length. When printing an invoice for a customer with a name bigger than 90 characters this will result in an error.
Go to Tools and enable the debugger (Breakpoint on Triggers is not required for this example):
Then, run the report. You will notice that the debugger stops here (when the error is thrown):
The question now is, can we trace this back to the report and see via which objects and code the report called this function?
Yes, we can. In the debugger you have a special window for this:
The little yellow arrow shows you in what object you are debugging. BUT, here comes the great feature, you can double-click on the underlying objects, and then the debugger will jump to the code of that object.
The little Green arrow shows now where we are debugging, and you can directly see which code in what object was responsible for calling the FormatAddr function.
Even more usefull you can see the object number, name and the trigger/function…
And you can even go further back by double-clicking on the object(s) below this one!
How cool is that?
Recent Comments