Model Driven software development for Business Central with “mdAL”

You might already have seen my session on DynamicsCon about Design Patterns. During that session, I mentioned a tool “mdAL”. If not .. well, here it is (starting at the mdAL part):

This tool has seen some major updates – time to blog about it. ;-).


I am not the developer of this tool – so not a single credit should go my way. The main developer of this tool is Jonathan Neugebauer, a German genius who made this for his master thesis, and who is putting this out there for free for us to benefit from. And I promise: we can benefit from this .. a lot!
I just discovered this tool by chance (basically Jonathan contacted me through my blog for a review) – and since I have been working on the very similar thing 18 years ago (VB.Net, generating code from Rational Rose (UML) models – don’t ask .. ), I was immediately hooked and saw immense potential!

Model Driven Engineering

To understand the goal of the tool, you need to understand what is meant with “Model Driven engineering”: it is a methodology that focuses on creating and exploiting domain models (let’s call it “design patterns”), which are conceptual models of all the topics related to a specific problem.

Indeed .. I got that from Wikipedia ;-).

Let me try to explain this by means of some …

Examples to convince you that this might be more useful than you might think ..

1- We want to create master entities where we implement the default stuff, like number series. A lot of this code is based on a pre-existing “model” of how to implement No. Series. Just imagine this can be generated in minutes…

2- We have a posting routine, based on a master table and documents. So we need journal, ledger entries, register, document tables, … and the codeunits for the posting routine. Every time quite the same, but a bit different. What we did in the old days: copy “Resource Journal” and all its codeunits, and start renumbering and renaming ;-). Just imagine this can be generated in a few minutes…

Don’t imagine, just install “mdAL” and “do”!

As you have seen in the video, all this is possible today, in AL, in minutes. Jonathan’s ultimate goal was to have a model driven AL, which basically means: you don’t write code anymore, you basically model it in an understandable language, and the code is generated for you.

Today, the tool has had a major upgrade, and now you can spit out code, without the necessity to have a full model. Basically meaning: you can now use it also as a pure code generator. In my opinion, this makes its functionality even more useful for the community!

The tool can be found on the VSCode marketplace here: mdAL – Visual Studio Marketplace. Please take some time to read through the comprehensive documentation he has provided as well here: mdAL ( It’s not long, and it’s well worth the read! It explains how to install it, a quick start, the snippets (yes, it has snippets – it’s not even going to be minutes, it could be just seconds 😉 ), and so on.

Let’s see how to handle the above examples

1- just master tables

Consider this:

This is an mdal-file with a description of my master-object “Container”. All this can be created with mdAL-snippets – so this really is just a matter of seconds. Very readable:

  • A master-object “Container”
  • A cart and list page
  • A template “Name”

Then, we simply “Generate AL Code”

And as a result, you’ll get compile-able code in many objects, with many models implemented. The generated code can be found in the src-gen folder:

It has…

  • implemented the table, with:
    • No. Series
    • Search Name with validation code
    • A blocked field
    • Comment, which is a flowfield to the default (and extended) comment table
    • Fieldgroups are defined (dropdown and brick)
    • Record maintenance to sub tables (commentline)
    • AssistEdit for No. Series
  • a setup table for the number series
  • A list page with
    • Action to Comments
  • A card page with
    • AssistEdit implementation
    • Action to Comments
  • A setup page in the right model
  • An enumextension for the comment line

And more!

How awesome is this? Don’t need comments? Remove it! Don’t need No. Series? Remove it!

Oh – did I forget to add “Dimensions” into the equation? Hold my beer…

Done! 2 seconds.
Result: we now have Dimension fields and code where necessary, like:

And even with events:

2- Posting Routine & Documents

Not enough? Then let’s now take it to a whole other level. Posting routines and documents.
Consider this:

I agree – it’s too simple, I need more fields – but look what happens when you generate code. All these files were generated:

A glimpse:

  • All posting codeunits with boiler plate code
  • Source Code implemented and extended in source code setup
  • Journal, Ledger entry and register
    • The journal already has 15 “boiler plate” fields (did you see how many I defined?)
  • Header and line with all boiler plating
  • Document number series as well
  • Document status (release/reopen)
  • Posting No. Series

Just too much to mention.

My conclusion and recommendation

My conclusion is simple: this is going to save us a crapload of time! Even if you “just” need some master table and some sub tables (yes, sub-entities are possible as well!). In my opinion it’s an unmatched level of code generation in our Business Central Development world. This is going into the extension pack!
My recommendation: play with it! Get used to it! Give feedback to it if you have any! And once you’re comfortable with it – thank Jonathan! ;-).

5.00 avg. rating (98% score) - 4 votes

Permanent link to this article:


2 pings

Skip to comment form

  1. Holy cow.

  2. Great! …like in others ERP!

    • MikeGlue on December 18, 2020 at 5:07 pm
    • Reply

    WOW !

    • Dave Machanick on December 18, 2020 at 8:44 pm
    • Reply

    This is like the old Navision Developer 2 manual in a single step.

  1. […] Model Driven software development for Business Central with “mdAL” […]

  2. […] Source : Waldo’s Blog Read more… […]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.