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

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
AL Extensions: Replace Document Attachment

AL Extensions: Replace Document Attachment

I have published a new simple, open-source extension that allows replacing existing document attachments in all master entities as well as in open documents. The source code as well as the app file that can be installed in your environment is available on my GitHub...

read more
Clean up your copied environments

Clean up your copied environments

One of the most important things every developer should handle is to clean up the environment when the environment (or a company) is copied. Especially if the environment is managed directly by a client and they can create new copies anytime. Similarly, for copied...

read more
7 git commands you should know

7 git commands you should know

For many years, developers in C/AL did not need to know anything about Git or other versioning tools. That has changed with Business Central, or more specifically with AL Language. Today, we will look at the most important (and basic) git commands any developer should...

read more
How to define the source for item reservations?

How to define the source for item reservations?

It's not uncommon to have a customer's request to limit from which source items could be reserved. For example, customers may not want to reserve items from return orders. How can we achieve this goal? It's really simple. All the magic is done in the procedure...

read more
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

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