Editar

Partilhar via


Development in AL

Note

We're working on improving the onboarding experience for AL developers. If you've input for this article, we'd love to hear from you. Please use the Feedback section at the bottom of this article to help us make improvements that you’d like to see.

We also welcome contributions to our docs. New to contributing to docs? Don't worry, read more about contributing here Contribute to the help.

Extensions are a programming model where functionality is defined as an addition to existing objects and defines how they're different or modify the behavior of the solution. This section explains how you can develop extensions using the development environment for Dynamics 365 Business Central.

If you're new to building extensions, we recommend that you read this document to get an understanding of the basics and terms you encounter while working. Next, follow the Get Started with AL to set up the tools.

Understanding objects in the development environment

All functionality in Business Central is coded in objects. The extension model is object-based; you create new objects, and extend existing objects depending on what you want your extension to do.

  • Table objects define the table schema that holds data.
  • Page objects represent the pages seen in the user interface.
  • Codeunits contain code for logical calculations and for the application behavior.
  • Report objects define the layout and data for reports.

For more information about the objects that you can create for your extension, see Extension objects overview.

These objects are stored as code, known as AL code, and are saved in files with the .al file extension. The AL Language extension for Microsoft Dynamics 365 Business Central also supports the multi-root functionality, which allows you to work with multiple AL folders within one workspace. For more information on how to group a set of disparate project folders into one workspace, see Working with multiple AL project folders within one workspace.

Note

A single .al file may contain multiple objects, however, it's a best practice to have one object per file.

Table extension objects and page extension objects are used to add or override changes to table or page objects. For example, consider a business that sells organic food, and the business wants to add two extra fields; Organic and Local Produce in its existing item table. The business uses a table extension object to define those extra fields. The table extension makes the newly added fields available for use in the item table. You can store data in these fields and access them by code. You can then use the page extension object to display the fields in the UI.

Note

Extension objects can have a name with a maximum length of 30 characters.

You have several options for creating new objects with the AL Language extension for Microsoft Dynamics 365 Business Central for Visual Studio Code. For more information about the objects that you can create for your extension, see AL Development Environment.

Developing extensions in Visual Studio Code

Using the AL Language extension for Microsoft Dynamics 365 Business Central for Visual Studio Code, you get the benefits of a modern development environment along with seamless publishing and integration with your Business Central tenant. For more information on the setup, see Get Started with AL.

Visual Studio Code and the AL Language extension for Microsoft Dynamics 365 Business Central let you do the following tasks:

  • Create new files for your solution.
  • Assists you with the creation of appropriate settings and configuration files.
  • Provides code snippets to help create application objects.
  • Gives compiler validation while you code.
  • Provides efficient publishing process. You can publish and see your code running by just selecting Ctrl+F5.

Note

For some users the Ctrl+F5 shortcut key may not work due to keyboard or other settings. If it doesn't work for you, run your code by choosing Run Without Debugging from the Run menu in Visual Studio Code.

Tip

Use Ctrl+Space to trigger IntelliSense and get assistance on code completion, parameter info, quick info, and member lists. For more information about snippets, see Syntax and snippets.

Extending the functionality of Business Central

You can extend the functionality of Business Central in several ways: you can extend tables, enumerations, application areas, pages, reports, code flows and the security model directly in AL. But you can also contribute directly to the base application in the open source projects for the system application modules.

For more information on the extensibility options available to AL developers in Business Central including examples on how to extend various features, such as extending item charges, best price calculations, and data archiving, see Extensibility overview.

Designer

Designer works in the client and allows you to design pages using drag and drop components. Designer lets you build extensions in the client itself by rearranging fields, adding fields, and previewing your changes in page design. For more information, see Use Designer.

Compiling and deploying

Extensions are compiled as .app package files. The .app package file can be deployed to the Business Central server. A .app package contains the various artifacts that deliver the new functionality to the Business Central deployment and a manifest that specifies the name, publisher, version, and other attributes of the extension. For information about the manifest files, see JSON Files.

Instrumenting your app with telemetry

Business Central emits telemetry data for several operations that occur when extension code is run. You can configure your extension to send this data to a specific Application Insights resource on Microsoft Azure. For more information, see Sending extension telemetry to Azure Application Insights.

Submitting your app

After development and testing are done, you can submit your extension package to AppSource. Before you submit the extension package, we encourage you to read the checklist to facilitate the validation process. For more information, see Checklist for submitting your app. To get code validation helping you to bring your extension package to AppSource, you can enable the AppSourceCop code analyzer. For more information, see Using the code analysis tool.

See also

Get started with AL
Get started developing Connect apps for Dynamics 365 Business Central
Keyboard shortcuts
AL development environment
XML comments in code
FAQ for developing in AL
Sending extension telemetry to Azure Application Insights