Writing your first AL extension
A first-walkthrough of building, publishing, and running a basic AL extension for Business Central — toolchain, project structure, and deployment.
This is the developer first-walkthrough. Setting up the environment is the most fiddly part; the AL itself is straightforward.
Toolchain. Install Visual Studio Code and add Microsoft's AL Language extension from the marketplace. That installs the AL compiler, language services, and debugger. You'll also want Git (for version control) and either a Docker environment for on-premise development or — far more common — a Business Central sandbox in your Microsoft 365 tenant for cloud development.
Sandbox. From the Business Central admin centre, create a new sandbox environment. Note its name, tenant ID, and the sandbox URL. The sandbox is free, fresh out of the box, and has demo data you can throw away.
Project. In VS Code, run AL: Go! from the command palette. Pick Microsoft cloud sandbox. Sign in with your tenant admin. The command scaffolds a new AL project folder with app.json (manifest), launch.json (debug configuration), and a sample HelloWorld.al page extension that adds a button to the Customer List.
Compile and run. Press F5. VS Code downloads symbols (Microsoft's compiled metadata for the platform and base app), compiles your extension, publishes it to the sandbox, and opens the sandbox URL on the Customer List. Your new action appears in the ribbon; clicking it runs your AL.
Make it your own. Replace the boilerplate with something useful. A common first step: a page extension that adds a custom field to the customer card, plus a table extension that adds the underlying column. Save, F5 again, see it live.
Codeunit and event subscriber. Next, add a codeunit with an event subscriber. Subscribe to OnAfterInsertEvent of the Customer table and write a debug log entry. Press F5; create a customer; see the log fire. You've now written extension behaviour that hooks into Microsoft's code without modifying it — the upgrade-safe pattern.
Source control. Initialise a Git repo. Commit early. The app.json and source files are everything you need.
Next steps. Read Microsoft Learn's AL language reference; experiment with permission sets, translations, and dependencies; and look at the AL-Go for GitHub template, which turns the project into a build-and-deploy pipeline.
Related guides
- AL events and integration patternsHow AL events let extensions hook into Business Central — business events, integration events, subscriber patterns, and what to avoid.
- AL extension architectureHow AL extensions are structured in Business Central — objects, namespaces, app.json, dependencies, and the runtime model.
- AL language and runtime evolutionHow the AL language for Business Central evolved from C/AL — runtime versions, language features added wave by wave, and what AL is becoming.
- Business Central CI/CD with AL-GoHow AL-Go for GitHub turns an AL extension repo into a build-test-deploy pipeline — secrets, environments, and continuous delivery.
- Business Central web servicesThe classic OData and SOAP web services in Business Central — how they differ from the v2.0 API, and when to use them.