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
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”:
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.
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!