Debugging and launch.json improvements in BC 2022 wave 2 (v21)

by Sep 21, 2022AL Language

Home 9 Development 9 AL Language 9 Debugging and launch.json improvements in BC 2022 wave 2 (v21)

In the new version of Microsoft Dynamics 365 Business Central, there are also some changes to the debugging and launch.json configuration.

Launch specific company

Having more than one company within your development environment is rare. However, having more companies in a sandbox environment or in a production environment is not so unusual. In that case, if you needed to test your modification or debug something in a different company, you had to switch companies manually. The new version brought a new launch.json parameterstartupCompany” where you can specify the name of the company that should be opened.

{
    "version": "0.2.0",
    "configurations": [
        {
            ...
            "startupCompany": "COPY COMPANY"
        }
    ]
}

Skip errors in the Try functions when debugging

Debugging some core processes could be really hard, especially if there are try functions. A quick reminder what is the try function – The Try function in AL Language is a special type of procedure in which any raised Errors are suppressed. Instead of showing the error message, the functions return true if there were no errors or return false if at least one error has occurred.

Until Business Central 2022 wave 2, if you debugged with breakOnError = “true” even these errors caused the debugger to stop at the line where the error occurred.

With the new version, this parameter has changed. Values true/false are still available, however, they should not be used anymore as they may be deprecated in the future. “True” should be replaced by “All”, and “False” with “None“. Furthermore, there is a new value “ExcludeTry” that behaves in the same way as All EXCEPT for errors in try functions that do not stop the process. In my opinion, it could be really helpful!

{
    "version": "0.2.0",
    "configurations": [
        {
            ...
            "breakOnError": "ExcludeTry"
        }
    ]
}

BreakOnRecordWrite only for non-temporary records

Similarly to the previous one, there is a new option for the BreakOnRecordWrite parameterExcludeTemporary. With this value, the debugger no longer stops at each record modification – it stops only when the “real” record is modified. It is once again a great enhancement, as you usually do not want to debug writes to temporary records, but only to records that really store data.

True/False are also still available, but as with the previous one, they should no be longer used but replaced by All/None.

{
    "version": "0.2.0",
    "configurations": [
        {
            ...
            "breakOnRecordWrite": "ExcludeTemporary"
        }
    ]
}

View SQL locks during debugging

One of the changes I like most is the possibility to see SQL locks directly in VS Code during debugging. SQL Locks are available directly in the Business Central client for some time, but to see locks when debugging, you had to open another client session and check locks there. It was really annoying, but now it is really simple – it is visible in the “Database statistics” section in VS Code and automatically updated when stepping through the code.

Recent Articles from the category

NavigationAction for ErrorInfo data type

NavigationAction for ErrorInfo data type

One more article about ErrorInfo data type. Have you already read my previous posts about ErrorInfo and Collectible Errors? ErrorInfo data type & Collectible Errors | MSDyn365 Business Central - Ing. Tomáš Kapitán (kepty.cz) Collectible Errors?! | MSDyn365...

read more
Error actions for ErrorInfo data type

Error actions for ErrorInfo data type

It is already almost one and a half years since the ErrorInfo data type was introduced (we saw this data type for the first time in BC2021w2). If you do not know what it is and how to use this data type, check my previous posts: ErrorInfo data type & Collectible...

read more
Data types under the microscope: List

Data types under the microscope: List

The List data type in AL language represents an ordered collection of objects that can be accessed by their index. Unlike an Array data type, a List does not have a fixed size and does not need to have its dimension specified when it is declared. The List data type...

read more
Connect to Azure Function in BC 2022 wave 2 (v21)

Connect to Azure Function in BC 2022 wave 2 (v21)

The new version of the Microsoft Dynamics 365 Business Central brought a new system module "Azure Functions" that makes integration with Azure Functions much easier and straightforward. The typical scenario, why to use Azure Functions together with Business Central,...

read more
Collectible Errors?! Is it already in use?

Collectible Errors?! Is it already in use?

Collectible Errors?! Is it already in use? This is the second part of my new article series about Collectible Errors. Let's check out the first part here: Collectible Errors?! | Microsoft Dynamics 365 - Ing. Tomáš Kapitán (kepty.cz) or you might be interested in my...

read more
Collectible Errors?!

Collectible Errors?!

Collectible Errors?! It has been already almost a year since ErrorInfo datatype & CollectibleErrors were introduced (I already have an article about basic structure: ErrorInfo data type & Collectible Errors). This article was released for the first time in...

read more
Substituting standard reports

Substituting standard reports

Report objects cannot be extended in versions previous to the Business Central 2021 release wave 1 version when ReportExtensions object was introduced. Since then, many of changes we need to do in reports can be done without creating a new copy of object. On the other...

read more

Sign Up for News

Certifications

Highest certification
Microsoft Data Management and
also in D365 Business Central

Microsoft Certified: Dynamics 365 Business Central Functional Consultant Associate

See other certifications here