AL expert teaches AI how to code AL

It’s clear by now that ChatGPT can’t really code AL, but what if we helped it a bit? Join me in this session, where I will try to help ChatGPT learn how to code AL:

https://youtu.be/FFBV9ysyXO8

In this video, Erik takes on an entertaining holiday experiment: teaching ChatGPT how to write AL code for Microsoft Dynamics 365 Business Central. The result is a fascinating (and often humorous) back-and-forth where Erik guides the AI through creating a table, card page, list page, and page extension — correcting mistakes along the way that are remarkably similar to what a brand-new AL developer might make.

The Premise: Can ChatGPT Actually Write AL?

AI tools like ChatGPT have been gaining traction everywhere, including in the Business Central community. ChatGPT seems to “know stuff” about AL, but as Erik notes, what he’s seen so far hasn’t been particularly useful. So he sets up a split screen — ChatGPT on the left, VS Code on the right — and starts a conversation to see if they can build something real together.

The very first interaction sets the tone: Erik mentions he uses AL:Go (the VS Code command to scaffold a new AL project), and ChatGPT immediately gets confused, thinking he’s talking about the Go programming language. A sign of things to come.

Step 1: Creating a Table

Erik asks ChatGPT to create a customer table in AL with Number, Name, and Address fields. The AI generates code, but it’s riddled with mistakes — the kind you’d expect from someone who’s just learning AL:

  • DataClassification was set to field names instead of proper values. Erik corrects it, suggesting ToBeClassified.
  • The Name field was the wrong type — ChatGPT used a “Name” type instead of Text.
  • Text fields were missing a length — Erik suggested setting them to 100.
  • The table was missing a primary key — ChatGPT added a key with Clustered = true once prompted.

After several rounds of correction, they arrived at a valid table object with three fields. Erik noted with amusement: “That table is just the way we wanted.”

Step 2: Creating a Card Page

Next up: a card page to display the customer record. ChatGPT’s first attempt was close but had several issues:

  • Missing the area element in the layout structure — ChatGPT forgot to wrap the group inside an area(Content).
  • Field names needed the Rec. prefix — on pages, field references must be prefixed with Rec..
  • DataClassification doesn’t belong on pages — ChatGPT added it anyway. Pages need ApplicationArea on fields instead.
  • ApplicationArea needed to be set to All — another correction Erik had to feed in.

What’s interesting is that ChatGPT remembered corrections from the table conversation and tried to apply them to the page — sometimes incorrectly. It put DataClassification on page fields because it had just learned about it for the table.

Step 3: Creating a List Page

The list page went more smoothly. ChatGPT:

  • Incremented the page number automatically
  • Remembered to use ApplicationArea and Rec. prefixes
  • Used a repeater control correctly

The main correction was that area should be Content, not List. Erik also had ChatGPT add the CardPageId property to link the list page to the card page.

Step 4: The Page Extension (Where Things Get Really Interesting)

The final challenge was creating a page extension that adds an action to the standard Customer List page to open the custom list page. This is where ChatGPT struggled the most — and where the corrections became the most entertaining.

The problems cascaded:

  • Missing area inside the actions section — Erik suggested using the Navigation area.
  • ChatGPT added a layout section that didn’t belong — page extensions for actions don’t need layout modifications.
  • Confusion between area and addlast — Erik had to explain the correct nesting: actionsaddlast(Navigation)action.
  • The promoted category and action parameters were wrong — needed Processing instead of Process, and the page reference needed fixing.
  • OpenPage vs RunModal — ChatGPT used a non-existent OpenPage function; the correct AL function is RunModal.

In the end, Erik had to make a few manual edits to get it compiling. The project’s source structure included the page extension extending the standard “Customer List”:

pageextension 50100 CustomerListExt extends "Customer List"
{
    trigger OnOpenPage();
    var
        HttpContent: HttpContent;
        JO: JsonObject;
        JA: JsonArray;
        T: JsonToken;
        Txt: Text;
        C: Code[100];
        Ref: RecordRef;
    begin
        Txt := '12345678';

        Rec.TransferFields();


        message(Txt.Substring(-3));
    end;
}

The app.json shows the project targeting Business Central application version 27.0 with runtime 14.0, using an ID range of 50100–50149:

{
  "id": "3c526bbf-3a6e-4a36-ae37-5eebeabc0bb5",
  "name": "AlWishList",
  "publisher": "Default Publisher",
  "version": "1.0.0.0",
  "dependencies": [],
  "platform": "1.0.0.0",
  "application": "27.0.0.0",
  "idRanges": [
    {
      "from": 50100,
      "to": 50149
    }
  ],
  "runtime": "14.0",
  "features": [
    "NoImplicitWith"
  ]
}

The Verdict: Fascinating, But Not Ready for Prime Time

After compiling and deploying, the extension worked — the action appeared on the Customer List, and clicking it opened the custom card page. But the journey to get there required constant hand-holding.

Erik’s key observations:

  • The mistakes ChatGPT makes are exactly the kind a beginner AL developer would make — wrong property values, missing structural elements, confusion about what belongs on tables vs. pages.
  • ChatGPT’s ability to remember context within the conversation is impressive — it built on previous corrections and tried to apply lessons learned (sometimes incorrectly).
  • The experience genuinely feels like teaching a brand-new developer — you explain something, they try it, they get it partly right, you correct them, and gradually you converge on working code.
  • The title is accurate: the AL expert taught the AI, not the other way around. Erik had to know exactly what the correct code should look like to guide ChatGPT to the right answer.

Conclusion

This experiment perfectly illustrates both the promise and the limitations of AI-assisted AL development. ChatGPT has enough knowledge of AL to produce something that looks like valid code, but the details — the areas, the prefixes, the correct property values, the proper action structures — require an experienced developer to catch and correct. It’s a useful tool for generating boilerplate and jogging your memory, but it’s far from replacing the need to actually understand the AL language and the Business Central platform. As Erik put it, the video title says it all: the AL expert teaches the AI, not the other way around.