Skip to content
Lubenheimer
Lubenheimer

  • Videos
  • About
Lubenheimer

Mastering Snapshot Debugging in Business Central

Posted on January 13, 2025

I have never been a big fan of the snapshot debugger in Business Central.
If possible, I always tried to create a sandbox for debugging with the specific to-do.

I never had the need to debug in a SaaS production environment – until now. So I jumped over my shadow and gave it a try, and surprisingly it worked really well. Not the results I had in mind when Snapshot Debugger was released.

But how can you do this yourself? Let me show you with a real Business Central bug 😉

Navigate to Help and Support and select “Attach debugger to this session”.

When you click on this feature, you will receive a notification in your browser:

By confirming this, Visual Studio Code will create a new generated project and download all symbols and also create app.json & launch.json:

When downloading the symbols, all dependencies of the object from which you called the function are taken into account. This means that you may either get additional .alpackages or you may be missing something. To find out, just check the app.json file as usual and extend it if necessary.

After that you’ll be asked how you want to debug depending on the environment you started the “attach debugger to this session” function from:

Select Snapshot debugging and take a look at the VSC terminal:

This is your “go, go, go” for debugging. Now you can perform the action you want to debug. Let’s try to debug an actual bug when creating new customers without a template:

After completing our task in VSC, we need to close the Snapshot Debugger session:

Find all your snapshots here:

Simply click the button at the bottom and select the Snapshot session you want to debug:

Now we can see the exact order in which the error occurs. So from this side it is a pretty easy way to get an idea about a bug really fast. But of course there are a few things to keep in mind:

Snapshot versus regular debugging
Breakpoints can be added or removed and they’ll be hit if the breakpoint is in the execution context of a recorded state. This means that if you walk the execution stack for a breakpoint and the next stepped line is reached, then the code will break on the breakpoint.
A snappoint is a breakpoint in Visual Studio Code that is set when creating a snapshot. They don’t, however, stop execution of code like when using regular debugging. Snappoints instruct execution to log the state at the breakpoint for later offline inspection.
You can always navigate through all the breakpoints with Continue (F5). The order may not be the same as the execution order on the Business Central server. This is because some calls on the server are AL calls with non-walkable stacks. Some are direct server calls on the server like triggers. A snapshot debugging session on the Business Central server can only record AL calls and walk AL stack traces.
This is also true when stepping. The rule of thumb is that breakpoints within the reach are hit first, and if there are none; the next line is hit. Breakpoints on triggers may not always qualify as code within reach.
Variable data is only shown on snappoints.
If there are no frames available, snapshot debugging will stop.
Stepping out of triggers with no recorded stack information will move execution to the first recorded method’s first line. This may be far from the user’s execution of interest. For example, stepping out from an OnOpenPage trigger with a snappoint may land on deep inside base code execution where recording has started. Navigating with F5 will start over breakpoint resolution, thus this is an exit strategy from a scenario like this.
A snappoint may resolve as a non-reachable breakpoint if there was no execution state on the server hitting the snappoint.
A snapshot debugger session with a Business Central server will be closed if not attached to after 30 minutes.
If a snapshot debugger session is started, it has to be finished after 10 minutes.

Snapshot debugging can be used on any Business Central production environment (17.2 or higher), regardless of whether you are using SaaS or OnPrem.

Find more information here:

Snapshot debugging – Business Central | Microsoft Learn


Discover more from Lubenheimer

Subscribe to get the latest posts sent to your email.

Allgemein

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

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

©2026 Lubenheimer | WordPress Theme by SuperbThemes

 

Loading Comments...