Setting Breakpoints

I discovered recently that it is possible for a running object to set its own breakpoints. I was debugging a problem with the inventory adjust cost codeunit (5895) and needed to step through the code for a particular item. Unfortunately, that item was one of the later items to be processed. I modified the code to check the item number and when the particular item was reached it wrote a record to the Breakpoints virtual table setting a breakpoint at the desired line of the codeunit. I turned the debugger on, started the process, it went through all the items until it reached the particular item, and stopped just where I wanted it. This requires 3.70 or later as that is when the Breakpoints virtual table was introduced.

Thanks Jack for such a useful tips.

Yes, this is very good news, I have been hoping for something like that for some time. I’m having difficulty setting a value for the following fields: Trigger Line Trigger Name Code No Of course, a bit of trial and error should find the correct number for Trigger Line, but is there something more convenient like a CurrentLineNo function? Or maybe a way of setting and naming a breakpoint, then using code to find and enable this breakpoint. Alastair

Yes I am interested in knowing how to retrieve the correct values to set the breakpoint too. Some sample code would be nice. [:D]

In the object designer, open the object in design mode and set a breakpoint on the line of interest (F9 to set a breakpoint). Close the object and exit the client. In “Documents and Settings<Your user ID>\Application Data” you will now find “NaviBP.xml” which will contain the info you are looking for. This file is used by the client to persist breakpoints across sessions.

Option 2: Step 1: Use the wizard to design a new form based on the Breakpoint table – add all fields. Step 2: Open the object of interest and set a disabled breakpoint at the point of interest (press F9 twice). Step 3: Run the new Breakpoints form – there it is! Step 4: Now, add code to the object of interest to detect the conditions of interest and when found, get the Breakpoint record and toggle the Enabled flag. (Careful – adding code to the object of interest may change the Key field values for the Breakpoint record…) What a feature…!

Thanks Fritz, I’ll try that. Alastair

Fritz, you da man!! [8D]

That is really interesting, but there is something I don’t understand.

If you knew the item you wanted to stop on, couldn’t you put a line like this in the code:

if Item No = myItemNo then blah := blah ; and then set a breakpoint on the “blah := blah” line of code? Then no inserts into a virtual breakpoint table.

That is the way I have been used for years. Simple and it works!


I’ve been programming during the last past 10 years in NAV and it’s the first time I’ve heard about this (undocumented ?!) feature

For those who were aware of those features, how did you learn about it ? in a training ? a document or just by experimenting stuffs with the virtual tables …

If you’ve other niceties to post, don’t hesitate for a second …