DEV Community

Eduard2207
Eduard2207

Posted on Fully Autonomous

From an AL object's structure to its source: inspecting Business Central .app packages in VS Code

When working with Microsoft Dynamics 365 Business Central, I often need to understand an object delivered inside a dependency package before I know which part of its source code to read. A table can contain many fields, triggers, procedures and events; opening a source file is not always the fastest way to locate the declaration that matters.

This article walks through a structure-first approach using Table 3 Payment Terms from the Microsoft Base Application. I use AL Structure Explorer, an extension I developed at SAN Business Solutions, as the example navigator. The technique is useful whenever you have permission to inspect an AL package locally.

1. Start with the package catalog

An .app is a Business Central application package. Before inspecting an object, establish the context: which application and version does the package represent? A familiar object ID can appear in different environments or versions, so recording the package identity helps make an investigation repeatable.

The catalog shown below lets me narrow the package by object type, ID or name. For this example, choose Table and locate ID 3.

Package metadata and object catalog with AL object type filters

2. Read the structure before the implementation

Think of an AL object as a hierarchy of declarations, not just a list of lines. Tables, for example, may contain fields, keys, field groups, triggers, procedures and events. Selecting one branch reduces the amount of source code that has to be examined.

Example structure tree for Table 18 Customer, including fields, properties and triggers

The screenshot uses Table 18 Customer to illustrate the hierarchy. For the Payment Terms exercise, follow this path instead:

Table 3 Payment Terms
└── Procedures
    └── Global
        └── UsePaymentDiscount
Enter fullscreen mode Exit fullscreen mode

Notice that the procedure is grouped by its visibility. This is useful when trying to distinguish an externally accessible declaration from a local implementation detail. The navigator is structural; it does not determine every possible caller or prove how the procedure behaves at runtime.

3. Navigate from declaration to source

Select UsePaymentDiscount in the tree. The navigator opens the corresponding AL source and highlights the declaration. This connects the structural information (where the member sits inside its object) to the actual source coordinates (where the implementation or declaration can be read).

Selecting an AL declaration highlights its corresponding location in the source editor

This example screenshot highlights an OnValidate trigger rather than the Payment Terms procedure. Both illustrate the same principle: select the relevant structure node, inspect its source location and then read the surrounding code for context.

For another object, the same approach can be applied to a page action, a report data item or an integration event. The useful starting point is the declaration category most relevant to the question you are investigating.

4. Understand the boundary of the analysis

There are several important distinctions:

  • A package that contains only symbols may not contain the source needed for this workflow. Source navigation cannot reconstruct undistributed AL source.
  • Conditional compilation can change which declarations are available to a parser. Compare the active configuration with the one used for the original build when necessary.
  • An object tree is not a dependency graph or a runtime call graph. Cross-package resolution and execution are different activities.
  • Keep track of the package version, and inspect only source you are authorized to access.

For reproducibility, the illustrated workflow uses desktop VS Code on Windows x64, .NET 8 and a separately installed compatible Microsoft AL backend. The extension's technical documentation describes the backend requirements and source limitations. Package inspection itself is local and does not require a Business Central server.

Video walkthrough

The YouTube demonstration shows the Payment Terms navigation example and other declaration types in context.

Takeaway

Starting with the package identity, then locating an object and finally following a declaration to its source is a practical way to narrow an AL investigation. It is especially helpful when exploring unfamiliar packages or reviewing what is available in a dependency.

The screenshots use publicly documented examples from Microsoft Base Application. Microsoft and the respective product names retain their ownership; the images do not imply Microsoft endorsement.

Disclosure: I am the developer of the tool shown in the examples. This article was generated with AI assistance from my existing technical materials.

Top comments (0)