Dynamics 365·7 min read·By Solzet

A C# Developer Inherits Business Central Extensions: Learn This First

A C# developer who inherits Business Central extensions should learn AL in order of risk, not syntax. First the extension lifecycle and upgrade codeunits, because a schema change or a careless upgrade can lose data in production, and an installed version cannot simply be rolled back. Then events and subscribers, because that is how extensions change standard behaviour and where most production bugs live. Then table and page extensions. Before touching production, put five safeguards in place in week one: source control, a sandbox copied from production, app version discipline, tests on posting, and a rollback plan. An AL code review or a short-term backup from a senior AL team covers the gap while skills build.

We recommend the right solution: Dynamics 365 (Customer Engagement, Business Central or Finance and Operations), Power Platform, or a custom-built CRM. One team for CRM, ERP and the integration between them.

Why is AL different from C# in ways that can hurt production?

The syntax is the easy part. AL looks like Pascal, has records instead of an ORM, and a C# developer reads it within days. What is different is the runtime around it. Your code does not own the database: it extends Microsoft's application and shares tables with Microsoft and with every other installed app. Schema changes are applied by the platform when an app is published and synchronised, and some of them are destructive or refused. Data written by your extension lives in tables that survive uninstall unless someone clears it. And a new version of an app, once installed, cannot simply be replaced by the previous version.

So the first question is not "how do I write a loop in AL" but "what happens to the data when I ship this". The rest of this guide is ordered by that question.

What should you learn first: the extension lifecycle or the language?

The lifecycle. Learn what publish, synchronise, install, upgrade, uninstall and unpublish do, in that order, and what each does to data.

  1. Publish puts the app package in the environment. Synchronise applies its schema to the database, and some changes, such as removing a field or changing a type, are refused in the normal sync mode because they would lose data.
  2. Install runs the app's install codeunit the first time it is installed in a company. Upgrade runs the upgrade codeunit when a higher version replaces a lower one.
  3. Uninstall removes the app but keeps its data by default, so a reinstall finds it again. Clearing data is a separate and deliberate step.
  4. Versions only go forward. Plan every release as something you cannot take back, which is why the rollback plan below matters.

Microsoft documents the details under developing and upgrading extensions on Microsoft Learn; read those pages before the language reference.

Why do upgrade codeunits come before everything else?

Because they are where data is lost. An upgrade codeunit, with Subtype = Upgrade, runs when a new version replaces an old one. If your new version moves a value from one field to another, splits a table or changes what a field means, the upgrade codeunit is the only thing that carries existing data across. Forget it and the new field is empty in production.

Learn four things early:

  • OnUpgradePerCompany and OnUpgradePerDatabase, and that upgrade runs once per company for company data.
  • Upgrade tags, which record that a piece of upgrade code has run so it never runs twice.
  • ObsoleteState Pending and then Removed, which is how a field or table is retired without breaking dependent apps or losing data in one step.
  • Install codeunits, which set up data the first time an app is installed, and why install code and upgrade code must not assume the other has run.

Then read the existing app's upgrade codeunits, if it has any. An inherited extension with schema changes in its history and no upgrade code is the first risk to write down.

How do events and subscribers work for someone who knows C# events?

The idea is familiar: publishers raise events, subscribers react. The differences matter. In Business Central, Microsoft's code raises integration and business events at defined points, such as before and after a sales document is posted, and your extension subscribes from a codeunit. You do not control the order in which several apps' subscribers run, so two apps that subscribe to the same event can affect each other, which is the usual cause of conflicts after updates (see ISV extension conflicts after an update).

Pay special attention to the IsHandled pattern. Many events pass an IsHandled parameter by reference; a subscriber that sets it to true tells the standard code to skip its own logic. That is powerful and dangerous: an inherited subscriber that sets IsHandled can silently replace standard posting behaviour. Search the code for every subscriber that sets IsHandled and understand each one before you change anything near it. Also learn that errors raised in a subscriber roll back the whole transaction, including the standard posting it was part of.

When do table and page extensions come in?

Third, because they are the most visible and the least risky part once the first two are understood. Table extensions add fields to Microsoft's tables; page extensions add fields and actions to pages. The rules a C# developer needs: fields added by different apps share the base table, so names and IDs must be unique, which is why publishers use an affix; field types and lengths cannot be changed freely once data exists; and flow fields and validation triggers run code you may not expect. If a publish fails in production with a field conflict, the diagnosis is on extension field conflict in production.

What five safeguards should be in place in week one?

Before the first change reaches production, put these in place. None of them needs deep AL knowledge.

  1. Source control: every inherited app in a repository, with the exact source of the version installed in production tagged. If you cannot prove which source matches production, download the installed apps' symbols and compare before changing anything.
  2. A sandbox from production: copy production to a sandbox in the Business Central admin center, so you develop and test against the same apps, versions and data shapes. Refresh it before every release.
  3. App version discipline: one version number per release, always higher than the installed one, with a short release note of schema changes and upgrade code. Never publish to production from a laptop.
  4. Tests on posting: at least a manual test script, and ideally automated AL tests, that post a sales order, a purchase order and the journals your extension touches in the sandbox before every release.
  5. A rollback plan: because versions only go forward, the plan is a fixed version ready to publish, or an uninstall that keeps data, agreed in advance with the business owner, plus knowing how to request an environment restore in the admin center for the worst case.

A build and release pipeline that makes most of this automatic is described on a build and release pipeline for one Business Central developer.

How long until a C# developer can change production safely on their own?

It depends on the extensions and the person, so set the bar by capability rather than calendar. A developer is ready to release alone when they can explain what each installed app does to data on upgrade, have read every event subscriber that touches posting, have released at least one change through the full sandbox, test and version routine, and have a rollback plan the business owner has seen. Until then, a second pair of eyes on every release is sensible insurance.

Where can a team get an AL review or short-term backup while skills build?

Solzet reviews inherited Business Central extensions and the changes a new AL developer prepares: upgrade code, event subscribers, schema changes and the release routine, with written findings your developer learns from. We can also act as short-term backup for a release, an update or a production issue, so your developer is not alone on the day it matters, and we leave the code and knowledge with your team. Our own senior AL developers do the work. The service line is Business Central AL development; broader implementation and support is on Dynamics 365 Business Central. Organisations that need a CRM next to the ERP without Microsoft licensing can look at custom CRM development.

A C# developer who inherits Business Central extensions should learn AL in order of risk, not in order of syntax. First the extension lifecycle and upgrade codeunits, because a careless schema change or upgrade can lose data in production. Then events and subscribers, because that is how every extension changes standard behaviour and where most production bugs live. Then table and page extensions. In week one, put five safeguards in place: source control, a sandbox copied from production, app version discipline, tests on posting, and a rollback plan. An AL code review or short-term backup covers the gap while skills build.

What do readers ask?

What should a C# developer learn first in Business Central AL?

The extension lifecycle and upgrade codeunits, because publish, synchronise, install and upgrade decide what happens to data in production. Then events and subscribers, then table and page extensions. Syntax comes along the way.

What is an upgrade codeunit in Business Central?

A codeunit with Subtype = Upgrade that runs when a new version of an app replaces an older one. It moves or transforms existing data for schema changes, and upgrade tags make sure each piece of upgrade code runs only once.

Can I roll back a Business Central extension to an earlier version?

Not by installing the lower version over the higher one. The practical rollback is a fixed higher version ready to publish, or an uninstall that keeps data, and in the worst case an environment restore from the admin center. Plan it before the release.

How are Business Central events different from C# events?

Microsoft code raises integration and business events and extensions subscribe from codeunits. You do not control the order of subscribers across apps, errors roll back the whole transaction, and the IsHandled parameter lets a subscriber skip standard logic, which must be reviewed carefully.

What safeguards should be in place before changing an inherited extension?

Source control with the production version tagged, a sandbox copied from production, version discipline with release notes, tests that post the documents the extension touches, and a rollback plan agreed with the business owner.

Does uninstalling an extension delete its data?

Not by default. Uninstall keeps the extension data so a reinstall finds it again. Clearing the data is a separate, deliberate step, so never use it as a quick fix in production.

Can Solzet review our AL code while our developer learns?

Yes. We review upgrade code, event subscribers, schema changes and the release routine with written findings, and can act as short-term backup for releases, updates and production issues while your developer builds skills.

Business CentralAL DevelopmentC# DevelopersUpgrade CodeunitsEventsExtensions

Have a project in mind?

Talk to a Solzet consultant about your CRM or ERP needs, whether that is Dynamics 365 (Customer Engagement, Business Central or Finance and Operations), Power Platform, or a custom-built CRM. We respond within one business day.