Reader small image

You're reading from  Mastering Microsoft Dynamics 365 Business Central

Product typeBook
Published inDec 2019
PublisherPackt
ISBN-139781789951257
Edition1st Edition
Right arrow
Authors (2):
Stefano Demiliani
Stefano Demiliani
author image
Stefano Demiliani

Stefano Demiliani is a Microsoft MVP on Business Applications and Azure, MCT, Microsoft Certified Solution Developer (MCSD), Azure Certified Architect, and an expert in other Microsoft related technologies. His main activity is architecting and developing enterprise solutions based on the entire stack of Microsoft technologies (mainly focused on ERP and serverless applications). He has worked with Packt Publishing on many IT books related to Azure cloud applications and Dynamics 365 Business Central and is a frequent speaker at IT conferences around Europe. In his free time Stefano is also a runner and a cyclist.
Read more about Stefano Demiliani

Duilio Tacconi
Duilio Tacconi
author image
Duilio Tacconi

Duilio Tacconi is a Microsoft Dynamics NAV/Microsoft Dynamics 365 Business Central Escalation Engineer at Microsoft EMEA Customer Support & Services (CSS). He joined Microsoft in 2008 after working in a customer IT department with a focus on system administration and development. Despite graduating with the highest score in Agricultural Science in 1996, he is in the ERP circuit since 1998 as developer and system implementer for several companies with Microsoft and non-Microsoft technologies. Currently, he is a subject matter expert in EMEA for RDLC Report development and one of Microsoft EMEA CSS reference for Managed Service for Partners (MSfP). Three times IronMan finisher, Duilio lives in Cernusco Sul Naviglio (Italy) with his beloved wife Laura and his 2 years old son Leonardo.
Read more about Duilio Tacconi

View More author details
Right arrow

Debugging

Dynamics 365 Business Central AL Language extension provides a debugger to help developers check, correct, or modify code so that custom extensions can build successfully, deploy smoothly, and act as expected.

Another way to track potential logical errors is to write test codeunits, but this will be a topic for another chapter. For now, we will see how to debug an extension and create tests for reports with ease.

This chapter will cover the following topics:

  • Running the AL Language extension in debug mode
  • Defining specific non-debuggable functions or variables
  • Mastering debugger and code editor issues (debugging the debugger)
  • Working with code analyzers
  • Using Event Recorder to track information about event availability

Running in debug mode

The basic concept behind debugging is the breakpoint, which is a mark that you can set on a statement. When the program flow hits the statement, the debugger is kicked in and suspends execution (technically, it breaks) until instructed to continue. Without any breakpoints, the code would run just fine as long as the debugger is active.

The debugger will automatically stop the execution of the code only when it encounters an error, or if it has been instructed in the launch.json file to break on record changes.

A developer could also use the debugger to find potential logic errors since the debugger enables them to execute AL code syntax, one statement at a time, while inspecting the contents of variables at each runtime step. In this way, the developer can check and match what is expected when they have designed the application extension.

You...

Understanding code analyzers

The AL language proactive debugging experience is greatly enhanced by code analyzers. Code analyzers are part of the standard AL Language extension, and are a set of contextual rules that are applied to extension development. These rules can generate an error or a warning when you're developing an extension.

Code analyzers can be enabled and disabled at will, both per workspace and globally.

To enable code analyzers, perform the following steps:

Go to File | Preferences | Settings (Workspace settings) | Extension | AL language extension and choose to edit the settings.json file.

You could also choose to edit the settings.json file by choosing user settings. However, since you might develop per-tenant extensions and also AppSource apps in the same environment, it would make more sense to have these enabled per...

Understanding Event Recorder

We all know that Dynamics 365 Business Central online development can only be done through extensions. Accessing code base extensibility is guaranteed by subscribing to standard event publishers.

Considering that there are several thousands of standard event publishers all over the application and the number is growing with every online update, finding the right spot to hook up a standard publisher is sometimes as hard as trying to find the proverbial needle in the haystack.

The recommended way to find out the appropriate entry point at which to subscribe is to use the Event Recorder.

This application feature is a must if you do not know what standard objects are, or you do not have access to the third-party source code in order to look at publisher definitions (in the event the code you subscribe to is part of a third-party extension or a private...

Summary

In this chapter, we have learned how to run the debugger and master its interface. We have also seen how to pin non-debuggable functions and variables in order to avoid showing private data when needed. We also inspected cool standard features that make our debugging and development life easier: code analyzers and Event Recorder. 

Now you're ready to debug extensions, to inspect events, and to analyze your AL code.

In this chapter, we have also saw how to catch runtime errors while inspecting code flow. In the next chapter, we will master how to detect logic issues (bugs) in application code through the development of automated tests.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Microsoft Dynamics 365 Business Central
Published in: Dec 2019Publisher: PacktISBN-13: 9781789951257
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Stefano Demiliani

Stefano Demiliani is a Microsoft MVP on Business Applications and Azure, MCT, Microsoft Certified Solution Developer (MCSD), Azure Certified Architect, and an expert in other Microsoft related technologies. His main activity is architecting and developing enterprise solutions based on the entire stack of Microsoft technologies (mainly focused on ERP and serverless applications). He has worked with Packt Publishing on many IT books related to Azure cloud applications and Dynamics 365 Business Central and is a frequent speaker at IT conferences around Europe. In his free time Stefano is also a runner and a cyclist.
Read more about Stefano Demiliani

author image
Duilio Tacconi

Duilio Tacconi is a Microsoft Dynamics NAV/Microsoft Dynamics 365 Business Central Escalation Engineer at Microsoft EMEA Customer Support & Services (CSS). He joined Microsoft in 2008 after working in a customer IT department with a focus on system administration and development. Despite graduating with the highest score in Agricultural Science in 1996, he is in the ERP circuit since 1998 as developer and system implementer for several companies with Microsoft and non-Microsoft technologies. Currently, he is a subject matter expert in EMEA for RDLC Report development and one of Microsoft EMEA CSS reference for Managed Service for Partners (MSfP). Three times IronMan finisher, Duilio lives in Cernusco Sul Naviglio (Italy) with his beloved wife Laura and his 2 years old son Leonardo.
Read more about Duilio Tacconi