Business Central as an app: getting to the al source code

This blog is actually not valid anymore. 

There is an official way to easily get to the al source code.  You can find more info here.

You must have heard the latest news: Microosft released the first devpreview (on docker) where Business Central is an app, and there is close to no C/AL anymore. Either you might have gotten it from the blog from Microsoft, or Stefano’s blog, where he explained how to build an app for it.

I wondered if there was still a way for us to browse the – in this case – the al-code. And even more – would we be able to use the VSCode navigationability (if that’s a word at all) to navigate our code (like “go to definition” and “find references”)?

And yes, it is possible :-).

Why do you think this is useful?

I never said this is useful, but it’s cool nevertheless to browse the entire AL codebase in VSCode. And yes, you can browse like a pro! Like:

Easily search for objects

Just search filenames with CTRL+P to easily find objects

Search Symbols

It also searches for symbols in the entire application

Search content of files

Or obviously just search for text in the files.

Go To Definition

The compile kicks in, so “Go To Definition” just works and lets you browse forward (and back) through the code. Much more convenient as in C/AL!

Find All References

Even the beloved “where used” is there with “Find All References”:

Reports

Last I like is the fact that you simply have all reports. So if you want to change dataset, just copy from this repo, and paste in your app, and you’re good to go.

So, how do I get to the al-source-files?

Well, to start with: this is just a workaround, and I can only imagine that at some point, the full source will just be part of some folder, github, whatever to download it from. But today, with the devpreview, we don’t have that yet.

Create an app

We will get the source from the symbols, so you need an app to download symbols ;-).

The trick to get to the symbols comes down to changing the app.json to create a dependency on the base app, and remove the “application”-tag, as you won’t be dependent from the application anymore (there isn’t any ;-)).

Pretty much like I did with my “Most Useless App Ever” here:

Having done this, you can download symbols, which will give you the Base App.

Open the downloaded symbol-file with 7zip:

And unpack it to a folder. You’ll see this will take a while.

Basically because it’s exporting +6000 files, a total of 190Mb. It will look like this:

And if you open the src-folder, you’ll see some pretty familiar files:

How cool is that? Well – not cool enough. I want to be able to decently search these files. So, I open the folder in VSCode, and start to turn this into an app.

So, Open it in VSCode

Build a manifest by simply open one of the al-files in the src-folder – if you open an al-file, you’ll see:

Make sure you:

  • Remove the ID-range (as this app is the full range)
  • Set target to internal (which is obvious, I guess;-))
  • And remove the “Application” tag again, since this app IS the application

When you save the app.json, you’ll get the question to download symbols:

And by doing that, it will create a launch.json for you that you need to correct connection to your server and you can “try again” to download symbols.

This should give you the system-symbols, which the app needs:

Now, you must have noticed that the filenames of the objects are quite weird (to say the least):

I noticed VSCode doesn’t really like that. So, what I did: I used my VSCode Extension “CRS AL Language Extension” to update all filenames.

I must admit – I had to do this a couple of times – it seems it’s a bit too many files for it ;-). If you just let it go, you should be good though .. And get this message:

If you have errors, just reload your window, and restart the rename until all files have a decent name.

When all is done, you should be good to go.

Disclaimer

This is just a workaround, and I can expect that the app will be there at some point in time in a better way (like a folder on the container, or github, or…). In that case, this complete blogpost will be obsolete.

The app does not fully compile in my case, which means it will not find all references, or symbols, … So it’s definitely not 100% trustworthy. But it’s “good enough” for now ;-).

Have a nice weekend!

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

Permanent link to this article: https://www.waldo.be/2019/03/01/business-central-as-an-app-getting-to-the-al-source-code/

21 comments

Skip to comment form

    • Fernando Tornero on March 4, 2019 at 5:30 pm
    • Reply

    Hello Waldo,

    And doing all the previous steps, don’t you have any issues with the DotNet vars and the dotnet.al file ?

      • waldo on March 4, 2019 at 5:50 pm
        Author

      Indeed , that’s why it doesn’t completely compile… no time to try to fix that though ;-).

    • vivek sarma on March 8, 2019 at 11:41 pm
    • Reply

    Hi Waldo,

    Thanks a lot for wonderful article. I have an issue and I hope you can help me on this.
    I tried creating new image from
    docker pull bcinsider.azurecr.io/bcsandbox:us and created a container.

    I modified the App.json to add following dependency and removed the application tag.
    {
    “appId”: “437dbf0e-84ff-417a-965d-ed2bb9650972”,
    “publisher”: “Microsoft”,
    “name”: “BaseApp”,
    “version”: “14.0.0.0”
    }

    However, iam not able to download the based app when I download the symbol.

    Please find my complete App.json file below

    {
    “id”: “2564e6e0-e78a-461f-ab77-213e286b199b”,
    “name”: “ALSourceCode”,
    “publisher”: “Default publisher”,
    “version”: “1.0.0.7”,
    “brief”: “”,
    “description”: “”,
    “privacyStatement”: “”,
    “EULA”: “”,
    “help”: “”,
    “url”: “”,
    “logo”: “”,
    “dependencies”: [
    {
    “appId”: “437dbf0e-84ff-417a-965d-ed2bb9650972”,
    “publisher”: “Microsoft”,
    “name”: “BaseApp”,
    “version”: “14.0.0.0”
    }
    ],
    “screenshots”: [],
    “platform”: “13.0.0.0”,
    “showMyCode”: true,
    “features”: [
    “TranslationFile”
    ],
    “target”: “Internal”,
    “runtime”: “3.0”
    }

    Please help!!

      • waldo on March 11, 2019 at 10:46 pm
        Author

      “bcinsider.azurecr.io/bcsandbox:us” is the wrong image.. . Read here: https://community.dynamics.com/business/b/businesscentraldevitpro/archive/2019/02/26/developer-preview-february-2019 .

      “bcinsider.azurecr.io/bcsandbox-master:14.0.28630.0-al” is where you can find aaaa (al-as-an-app :-)) …

  1. Settings.json needs an extra bit to be able to do a full compile…

    “al.assemblyProbingPaths”: [
    “C:\\Windows\\Microsoft.NET\\assembly”,
    “C:\\Nav\\14.0.28630”
    ],

    The Nav Client and service tier need to be under C:\NAV\14.0.28630

  2. Thanks so much for figuring that out 🙂

    • Aitor on April 4, 2019 at 9:50 am
    • Reply

    Hi Waldo,
    Great article, liek always. One question, might be stupid…. Where can I get the appID? For example, in a cloud BC, might be the ID from the URL?

    Thank you very much

      • waldo on April 4, 2019 at 11:59 am
        Author

      You can always get app info from the extensions management page. Is that what you mean?

      • Aitor on April 4, 2019 at 12:06 pm

      I understand.. So you must put the appID of one of the loaded extensions.
      I thought that it was like a relation to the instance itself… i thought that because I think that you download all the objects. Or do I download all the objects, no matter the appID?

      • waldo on April 5, 2019 at 8:42 am
        Author

      What I did is download symbols. For this, I need dependency, for which I needed the AppID.
      By downloading the symbols, I got a .app-file that includes all code.

      All this was just to ge to the code. At a later point, we will be able to get to the point in a different way. LIke a public repo or something like that…

    • Somasree Kar on April 27, 2019 at 3:11 pm
    • Reply

    hello i can ee only two files got downloaded, Microsoft_Application_14.0.29537.0.app and Microsoft_System_14.0.29530.0.app. what to do

      • waldo on April 30, 2019 at 12:44 pm
        Author

      you must have used the wrong container image – if the baseapp is an app, you shouldn’t get “application” symbols…

    • Luca on April 30, 2019 at 12:38 pm
    • Reply

    Hi Waldo,

    if i créate a field 50000 into a TabExt of table Ítem, i can view this field from the BaseApp? For example from the CU 80?

    Regards.

      • waldo on April 30, 2019 at 12:43 pm
        Author

      well no .. your app is dependent from the base app, not vica versa…

    • AitorNAV on July 17, 2019 at 12:41 pm
    • Reply

    Hi Waldo,
    As far as i understand, I need to pull into the docker the “bcinsider.azurecr.io/bcsandbox-master” image, am I right?
    Is not possible with “mcr.microsoft.com/businesscentral/sandbox”? If that, is because I need the next major release, right?

    Thnak you as always, great post!!

      • waldo on July 17, 2019 at 2:10 pm
        Author

      No, this was a blog specifically for one Docker image (look at the links I referred to). Although, if I were you, I would wait for the 2nd of August. Microsoft will make it available as preview then (as you can read here: https://community.dynamics.com/business/b/businesscentraldevitpro/archive/2019/02/26/developer-preview-february-2019).

      They way I describe it in this blog, will not be supported by microsoft (for the better .. because it ‘s a major detour ;-)).

      • AitorNAV on July 18, 2019 at 7:29 am

      Perfect, I will wait to pull into the docker after the summer to work with it
      Thanks again!

    • Mark Landman on August 2, 2019 at 7:37 pm
    • Reply

    does this still work? and where can i find the current verion.

      • waldo on August 5, 2019 at 9:45 am
        Author

      No, don’t follow these guidelines anymore – at this point, new insider builds are ready, and now you are able to “just” get it from the image.

  3. Hi, the “Find All References” does not display “Where used” from other objects within the BaseApp, E,g External procedure WhseShptLn.CheckSourceDocLineQty(); The “Go to Definition (F12)” does navigates to the procedure. If I then on the CheckSourceDocLineQty() ask for “Find all Refeferences (Shift+Alt+F12)”: it does not provide any more information exept for my local project files. For the record, CheckSourceDocLineQty() is been called from two places OnValidate and Codeunit “Whse.-Create Source Document”.
    I had expect that “Find All References” would displayed those two calles, togheter with my extension.

      • waldo on September 13, 2019 at 9:14 am
        Author

      I hope you didn’t apply what’s on this post, as it’s actually now just out-of-the-box available when you create a new master-insider build.

      I have the feeling it does find all references when you just get the official insider docker images.. .

Leave a Reply

Your email address will not be published.

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