Editar

Partilhar via


Get started with 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.

To start writing extensions for Dynamics 365 Business Central, you need a Business Central tenant, Visual Studio Code, and the AL Language extension for Microsoft Dynamics 365 Business Central. Visual Studio Code is a cross-platform editor that you use for coding and debugging.

Steps to set up a sandbox environment and Visual Studio Code

Go through the following steps to set up a sandbox environment. Having set up a sandbox environment, you get sample code that compiles and runs with just a few commands.

Note

If you want to create a container-based sandbox, see Get started with the Container Sandbox Development Environment. For information about which sandboxes you can choose, see Sandbox Environments for Dynamics 365 Business Central Development.

Important

It's not supported to publish an extension from Visual Studio Code with the same identifiers as an extension, which is already published to AppSource. Identifiers include the combination of appID and version or name, publisher, and version. If you do publish such an extension, it can be removed at any time.

  1. Sign up for a Dynamics 365 Business Central sandbox.
  2. Download Visual Studio Code.
  3. Download the AL Language extension for Microsoft Dynamics 365 Business Central.
  4. Select Ctrl+Shift+P to open the User Settings window; here you can modify the telemetry settings.
  5. Select Alt+A, and right after, Alt+L to trigger the AL Go! command, choose a path to a new empty folder and which version to run. Then choose Microsoft cloud sandbox as the server.

    Tip

    When no folders are opened, the primary side bar for the Visual Studio Code Explorer has a Create AL Project button. Clicking this button invokes the AL:Go! command to create a new project.

  6. Enter the credentials that you provided for the sign-up.
  7. Select Ctrl+F5 to deploy and run the extension on your online sandbox tenant.

Note

For some users the Ctrl+F5 shortcut key might 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 dropdown in Visual Studio Code.

Note

If you want to change your configuration at a later point in time, you can do so in the launch.json file. Just choose the Add Configuration button on the bottom right side, and then choose one of the available options. You don't have a launch.json file until you have run the AL:Go! command.

You now have a HelloWorld sample that compiles and runs. The JSON files in the project are automatically updated with the settings that allows you to select Ctrl+F5 to build and deploy the solution to Business Central. For more information, see JSON Files.

Tips and tricks

  • Use Ctrl+Space to activate IntelliSense at any place in the code, which helps you identify possible options.
  • Always use the .al extension on new files.
  • Use the built-in snippets for code by typing t and choose the desired snippet from the list.
  • Create objects within the right object ranges, see Object Ranges in Dynamics 365 Business Central.
  • Build and get inspired by our sample library on GitHub.
  • Use Ctrl+Shift+P and select AL: Clear credentials cache to clear the credentials cache if you want to deploy against a different environment.
  • Use F2 to rename objects, types etc. For more information, see Keyboard Shortcuts.

JSON file settings

There are three JSON files in the project; the app.json file, the launch.json file, and the rad.json. The files are automatically generated for your project. For more information, see JSON files and Work with Rapid Application Development (RAD).

AL configuration settings

Use the AL configuration settings to specify general preferences for working with AL projects. For more information, see AL Language Extension Configuration.

Telemetry settings

By default, Visual Studio Code is set up with a telemetry system to make sure that data and errors are sent to Microsoft. If you don't want to send telemetry data, you can change the telemetry.enableTelemetry setting from true to false.

To modify the telemetry setting, select Ctrl+Shift+P in Visual Studio Code and choose User Settings, which opens the settings.json file, and then add telemetry.enableTelemetry and set it to false like shown in the following example.

"telemetry.enableTelemetry": false,

Tip

The settings.json file contains user and workspace settings, these options can be modified to suit your preference. If you want to modify Visual Studio Code editor options and functional behavior settings, see User and Workspace Settings.

Installing and publishing an extension

To make your extension available to users, the package must be published to a specific Business Central server instance. The extension can be installed for one or more tenants. For more information about how to install and publish an extension, see How to: Publish and Install an Extension.

Controlling user access to develop and publish extensions

The access to develop and publish extensions is controlled on a user or user group basis by the EXTEN. MGT. - ADMIN permission set. It's important that the EXTEN. MGT. - ADMIN isn't specified for a specific company, but left blank.

If you add new permission sets and want to control the access to develop and publish extensions, you must include indirect read and write permissions to the Published Application table (read – for downloading symbols, write – for publishing the app) in the permission set.

To prohibit a user from publishing, just remove the user from the EXTEN. MGT. - ADMIN permission set.

Note

The EXTEN. MGT. - ADMIN permission set was introduced in Business Central 2021 release wave 1 as a replacement for the D365 EXTENSION MGT permission set in earlier versions.

Next steps

Now that you have the tools and the HelloWorld example up and running, you might want to create a small sample app in AL. This walkthrough guides you to create an app adding objects, code, and publishing the app to your tenant. For more information, see Build your first sample extension with extension objects, install code, and upgrade code.

AL development environment
FAQ for developing in AL
Syntax
Build your first sample extension with extension objects, install code, and upgrade code
AL Language extension configuration
Documenting your code with XML comments