One PTE, Four Apps: Designing a Business Central Extension for Its Whole Lifecycle
Note: This blog is a personal notebook. I write it to record what I work on, for my own reference, not to publish it on social media or to promote myself. If a post is still useful to you, I am glad, but that is not why it exists.
This post was published on February 07, 2026. Software versions, product features, links, and tool availability may have changed since then. Always check official documentation for the latest information. Some screenshots show small details. Zoom in on the page to see them clearly.
This post goes back to the core of the job: designing and delivering an extension for a Business Central customer. The example is a small demo per-tenant extension (PTE), MBS Site Inspection Scheduling. It schedules inspections at customer sites, records the findings, and posts them to history.
The scenario is simple on purpose. The interesting part is the structure around it, on two layers:
- The delivery layer. How the repository and its apps support build, test, performance test, demo, and upgrade.
- The app layer. How the main app models its data and its posting routine.
Problem
A typical PTE starts as one app folder. Tests, if any, live in the same app, demo data comes from a manual sandbox setup, and performance is checked when a customer complains.
This breaks down at the second or third release wave. A test library becomes a dependency of production code. The demo setup disappears with a deleted sandbox. A posting routine that was fast with ten records is slow with ten thousand.
Why this matters
A customer pays for the main app. The partner pays for the tests, the demo, the performance checks, and the yearly upgrade. A theatre works the same way: the audience pays for the play, but the rehearsals and the stage crew make the second night possible.
Microsoft also releases two major versions each year. A PTE that cannot build and test against the next version early puts the customer’s upgrade window at risk.
Architecture, part 1: the delivery layer
The correct terms
In AL-Go for GitHub, a project is a folder that AL-Go builds as one unit. It can hold more than one app. This single-project PTE repository lists four app folders in .AL-Go/settings.json: the main app and three companion apps.
| Folder | Role | AL-Go setting | Object IDs |
|---|---|---|---|
App |
Main app: tables, pages, posting, permission set | appFolders |
50000..50099 |
App.Test |
Automated tests, 25 test methods | testFolders |
50100..50199 |
App.PerformanceTest |
Business Central Performance Toolkit (BCPT) scenarios | bcptTestFolders |
50200..50299 |
App.Dataset |
Contoso Demo Tool module for demo data | appFolders |
50300..50399 |
Dependencies flow one way
Each companion app depends on the main app. The main app depends on nothing, so the customer gets one .app file with no test or demo code in it.
Internal by default
Every table and posting codeunit in the main app has Access = Internal. internalsVisibleTo in app.json opens them to the three companion apps only. A small public surface makes future changes cheaper: you cannot break a caller that cannot exist.
The app also sets target to Cloud, turns on NoImplicitWith, and sets allowDownloadingSource to false. Each line in app.json is a decision, not boilerplate.
Namespaces
AL namespaces follow the functional areas: MBS.SiteInspection.Setup, .Scheduling, .Posting, .PostedInspection, .Ledger, .Permissions. The folders use the same split, so a new developer finds the posting code without a search.
What each companion app proves
- The test app proves the business rules. Each test builds its own data (
MBS Library - Inspectionplus Microsoft’sAnylibrary), so no test depends on another. - The performance test app measures cost under load: create, bulk create, post, bulk post, and two query patterns. Two scenarios run parallel sessions against the same site or inspector to show lock contention.
- The demo data app makes the demo repeatable. One Contoso Demo Tool run creates setup, types, open and overdue work, ready-to-post documents, and posted history.
The pipeline
The standard AL-Go PTE workflows build and test all four apps on each push and validate every pull request.
For the yearly upgrade, the Current, NextMinor, and NextMajor workflows build and test the same code against the current and next versions of Business Central. A breaking change shows up weeks before the customer’s update window.
Architecture, part 2: the app layer
Reuse the standard model
The app adds no master data that Business Central already has. A site is a Customer, an inspector is a Resource of type Person, numbering uses No. Series, and audit uses Source Code Setup with one added field. The customer keeps the cards, permissions, and reports they already know.
The table set
The data model follows the standard document pattern. If you know sales documents, you know this structure.
| Level | Tables | Purpose |
|---|---|---|
| Setup | MBS Inspection Setup |
Number series and defaults |
| Master data | MBS Inspection Type |
Reusable categories, such as Safety or Compliance |
| Open document | MBS Inspection Header, MBS Inspection Line |
Planned work and checklist findings |
| Posting buffer | MBS Inspection Journal Line |
The data that the ledger posting routine receives |
| Posted document | MBS Posted Inspection Hdr., MBS Posted Inspection Line |
The history of what was inspected |
| Ledger | MBS Inspection Ledger Entry, MBS Inspection Register |
One entry per posting, grouped by register |
| Shared | MBS Inspection Comment Line |
Comments for types, open documents, and posted documents |
One comment table serves all three levels through an enum field, Table Name, like the standard Comment Line table.
The posting routine
The posting code uses the standard split: confirm, document posting, journal check, and journal post codeunits, each with one job.
Three design choices are worth a note.
- The journal line is the only input to the ledger. The journal post codeunit never reads the inspection header, so a later correction journal can reuse it.
- The posting number commit comes first, as in standard sales posting. After a failed transaction, a retry uses the same number.
- Locks are taken late and in a fixed order: the ledger entry table, then the register table. This lowers the deadlock risk when two users post together, and the BCPT contention scenarios test it.
The ledger and register
Each posting writes one MBS Inspection Ledger Entry with the type, site, inspector, dates, a short result summary, the source code, and the user. The register records the entry numbers of each posting.
The ledger has secondary keys on site, inspection type, and inspector, each with the posting date. They match the business questions: which sites keep coming up, which types fail most, and what each inspector did last month. Design the keys for the questions, not for the screens.
Access
One assignable permission set, MBS Insp. All Users, covers every object. That is enough for a demo, but not for a customer.
Demo steps
Prerequisites: a Business Central 28.0 or later sandbox, plus Microsoft’s Contoso Coffee Demo Dataset for the demo data.
- Clone the repository and open
al.code-workspacein VS Code. - Publish
Appto your sandbox. - Publish
App.Dataset, open Contoso Demo Tool, and generate the Site Inspection Scheduling module. - Open Inspections and post a ready document with F9.
- Follow the posting through Posted Inspections, Inspection Ledger Entries, and Inspection Registers.
- Run the test app from the AL Test Tool, or push a branch and read the AL-Go CI/CD run.
What is intentionally simple
- One ledger entry type (Inspection) and one permission set.
- Overdue is a filter (open status, past planned date), not a stored state.
- No reports, APIs, role center, integration events, or telemetry.
- Demo-scale data and demo-grade tests.
Risks and limits
The repository README lists its own gaps. The important ones:
- Posted history is read-only only on the pages. The posted and ledger tables have no guards against modify or delete, and the permission set grants full access (RIMD). For a customer, I would make them insert-only.
- There is no role separation. A coordinator, an inspector, and a reviewer need different permission sets.
- Status transitions are not enforced, except that posting requires Closed.
- Two setup fields have no logic yet:
Default DurationandOverdue Threshold Days. - The demo data app is in
appFolders. Keep it out of customer production deployments. - The demo is not production-ready and is not validated for AppSource.
Next iteration
- Enforce immutability on the posted and ledger tables, enforce status transitions, and split the permission set by role.
- Add integration events around posting, so a second PTE can extend the routine.
- Use
Overdue Threshold Daysin a cue or FlowField, or remove it. - Tighten the tests so each assertion matches its test name, and run the permission test with test permissions on.
- Add a report on recurring site issues. The ledger keys already support it.
Closing note
The business logic here is small. The structure makes it maintainable: a clean main app, a narrow public surface, companion apps, and a pipeline that builds against the next release before the customer gets it. The same structure scales from a 10-user PTE to a multi-customer add-on.
The code is public. Read it, criticize it, and reuse what fits: mbaic/mbs-site-inspection-scheduling.