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

BC Open Source? How to start?

BC Open Source? How to start?

BC Open Source? How to start? One of the most exciting news introduced last month in Lyon during Directions EMEA 2023 was the changes to the open-source initiative. This means that you can now contribute to the source code of the Base app and the System app, which are...

read more
Validate a FlowField Field. Wait? What?

Validate a FlowField Field. Wait? What?

Validate a FlowField Field. Wait? What? There are not many things in the AL Language that surprised me. However, last week, I found one such thing - I reviewed customizations made by another partner and had to analyze the OOTB code of the Demand Forecast matrix. I run...

read more
Dynamics NAV 2013 & Expired Cronus License

Dynamics NAV 2013 & Expired Cronus License

We found an interesting problem - we were not able to run the development environment for Dynamics NAV 2013. Whenever we tried to run the development client, we got the following error message: "Your program license has expired" and the development client has closed...

read more
Indirect Dependencies and Access Modifiers

Indirect Dependencies and Access Modifiers

Last week, there was a discussion on Yammer on how to get values from the "Sent Email" record when all fields are marked as Internal. I was surprised that many people do not know what can/can't access modifiers (such as local, protected, or internal) be used for. I...

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