Set up Visual Studio Code for Dynamics 365 Business Central development

>> Hello and welcome to this video in which I will talk about setting up Visual Studio Code for Microsoft Dynamics 365 Business Central The goal of this video is to learn about the elements of the modern development environment and how you can prepare your environment to start developing your own extensions for Business Central My name is Daniel Rimmelzwaan and I am a partner with Cloud Ready Software, one of the ISV Development Centers who can help you with just about anything related to Microsoft Dynamics 365 Business Central The agenda for this video are four points First of all, I will talk about the development environment and all of the elements that you need to be able to develop an app for Microsoft Dynamics 365 Business Central Next, I’ll show you Visual Studio Code in general terms, also known as VSCode and I’ll show you what that looks like, how it works and how you can extend its functionality to suit your needs The third topic is about the AL Language Extension for VSCode and all of the pieces that are part of that extension Lastly, I will show you how you can create a new AL project and how to connect that to a running instance of Dynamics 365 Business Central As I said before, the goal of this video is for you to be ready to start programming your new functionality So at the end of this video, you should be ready for the next one about developing in Visual Studio Code So let’s get started Let’s explore the Development Environment Now, everything we do, we do with Docker So, when we set up a development machine, we will set it up with Docker and I’ll show you how that works There’s two ways how you can do this One is by creating an Azure VM and in Azure VM, you can use a Sandbox template for Business Central You can go to this link aka.msBusinessCentalApps, and in there, there should be a couple of templates that you can use to create a development sandbox All the necessary elements will be prepared for you if you go this route The other way to do it is to create a local environment and this can be your own computer or on a virtual machine that runs locally So, regardless of what you have installed as the operating system on that VM or your computer, there are two operating systems for which a Docker can be installed Windows 10 is a little bit more difficult than Windows Server 2016 and so, our virtual machine, our Azure VM has been set up with Windows Server and I use Windows Server 2016 for my local virtual machine, myself So, I host machine itself, my laptop is Windows 10 Pro and then inside there, I have Hyper-V installed and Hyper-V runs a virtual machine that has Windows Server 2016 and inside of that, I have Docker installed You can follow these two links to read exactly how this works Next, we install the navcontainerhelper PowerShell module Freddie Christiansen has created a module for PowerShell which you can download from the PowerShell gallery and it’s also available in open source on GitHub So, follow the link in your screen to go into that actual GitHub repository to see what’s all in that NavContainerHelper There are some wonderful PowerShell stuff in there that you can use for inspiration So, run it in PowerShell ISE, install module navcontainerhelper, turn the force flag on and that should install the NavContainerHelper PowerShell module inside of there Then from there, you create a new NAVContainer and so you use the right Docker image for your purpose So, there are many images available for different versions of NAV and also different versions of Dynamics 365 So, you need to know which image you want to use, you can pull that image down and from that image, you can then create new NavContainers using the NavContainerHelper PowerShell module So, for this video, we use an insider built for Business Central Business Central, at the time of recording this video, has not been released yet So, we are using an insider build to show you and of course, you need a proper NAV partner developer license One more thing about documentation, if you go into the GitHub repository for NavContainerHelper, there are a number of links in there and the one that you’re looking for are a link for the end to end documentation and also a link to a hands on lab

With those two, you can walk through the entire installation and walk through all the elements that come along with building a NavContainer with Docker Also, there’s a video on how to set up NAV Docker and how to use Docker for this purpose where we go into all the details So if you want to learn more about those details, feel free to read about that The easiest way is to use one of those sandbox templates You specify the version that you need, you specify a name for it and then you run it, you let it go and then about an hour later, you have an Azure VM that’s fully set up and all the necessary elements are prepared in there for you and it’s just ready to go Very easy, very clean Let’s walk through the elements of the Development Environment As I said, a Docker container and this Docker container includes a Web Client, a Windows Client, access to C/SIDE, PowerShell with those NavContainerHelper modules preloaded and a Command prompt. Those Command prompts, PowerShell, Windows Client, all connects to the Docker so you’ll have shortcuts on the desktop inside of your virtual machine but also when you install this Docker container from a local computer or your local virtual machine, it will generate all those shortcuts for you NavContainerHelper, obviously, that’s the PowerShell module that connects into the Docker container where you can use all these commands to do a variety of container manipulations, object manipulations, et cetera So it’s important that you kind of go through the module, the NavContainerHelper module to get familiar with the commands that are available for you and a variety of videos that will provide for a variety of purposes One thing that’s important about understanding how Docker works is, it’s a virtualized service almost and so, it’s a self-contained piece that has virtual folders inside of it and inside the container, there’s a drive letter So there’s a C drive with folders and one of the folders inside of the container is mapped to a folder on the host with the same path So, I’m going to show you this entire environment in just a few minutes and I’ll show you where the location of that file exchanges So when you import an object, you can use the NavContainerHelper command-let to import objects and point to a folder on the C drive that maps to a folder with the same path inside of the container So it’s a shared folder, so anything that you put in there from within the container is visible on the outside and anything that you put in there from the host is also available and visible from within the container So you could enter the container and see the content of a folder inside the container but because it’s mapped to the same folder on the host, it will show the same thing I’ll show you how that works in just a few minutes Next element is Visual Studio Code, also known as VSCode VSCode extensions are, the ones that we are going to be using is the AL Language, PowerShell, I’ll show you Team Services is a very useful extensions, et cetera So, I will go over the details of Visual Studio Code a little bit later in this video but that’s one of the elements of the Development Environment Another important piece is Source Code Management Visual Studio Code is integrated with Source Code Management by using Git So, Git protocol is part almost of Visual Studio Code You have to install Git and set it up in order to be able to actually use it but it’s fully integrated with it So, once you’ve set it up, you start programming, you’ll see that VSCode actually keeps track of all your changes and you can go into the Source Code Management area and see all the changes that you’ve made So, very useful stuff Another part of Source Code Management are work items and a Repo in the,

for instance, Visual Studio Team Services Work Items are units of work that can be set up in a certain way in Visual Studio Team Services also known as the online version of Team Foundation Server and those work items can be linked to items in the Git Repository So VSTS is capable of providing a Git Repository as part of a project inside Team Services and you can connect it to Visual Studio Code and you can check in and check out objects from there and clone Repos and all that sort of stuff, all that good stuff When you check in, when you push change into the Central Repo, you can check it in while linking it to work items So in Team Services, you can see the interaction between those two parts of the system All of this is done with a Decentralized Development Approach So, we will be talking about all of this where the developer, you, has a local copy of the environment So, we are not connecting to a central database, a central NAV database where we do object We have our own local copy of the entire project We’re doing our work and then when we are done, we are checking in our changes into Source Code Management That gets deployed and distributed with, if you’ve set that up with a built server or in any other way So, that’s about the elements I think it’s time for us to go into the Development Environment and I’ll show you around We are in the Azure VM, connected to the Azure VM through remote desktop The first time you open it, it’ll show a couple of things So, the first thing that you see in this screen is what’s called the landing page If you look at the desktop shortcuts, there’s also a shortcut for the landing page So, if you close this by accident, just double click this guy over here and it’ll take it back up A few important things about the landing page, this is kind of an important dashboard Here is the information for the Self Signed Certificate If you need to set that up, Remote Desktop Access, you can click on this and that’ll download a RDP file that connects to it So if you’re on your host, this is what you do You get the link out of your Azure portal. In fact, let me show you This is a browser window on my own laptop where I have opened– Let me see if I can show you that guy This one, I’m not sure if this is going to work for very much longer I think there will be a different link to one of those Azure VM templates but if you go to that link I showed you before, the, that will give you access to this templates So, what you get is a template where you just enter the details of your virtual machine So you give it a VM name, you show as Accept the EULA, Remote Desktop Access, I leave that alone You get to pick the VM Size, the Standard D2 V3 is big enough for most development purposes than I’ve ever used this for VM Admin Username, Nav Admin Username I always give this a different value, so it’s always the same for me I change my password around, of course Then the NAV Docker Image for the developer preview, we’ve always used the image called microsofts/dynamics-nav:devpreview-finus and whatever version is uploaded for that image is what the virtual machine will pull when it’s being built So this is a template. So you can create your own virtual machine based on a completely different version So if you enter that in here, the Nav Docker image in here, it’ll create a virtual machine based on the Docker image that you specify in here Then you give it the URI to the License File,

we have this in a Dropbox Make sure that you set the download tag to one instead of zero, otherwise that will fail Run Windows Update, I always do this It takes a little bit extra time but then you don’t get the annoying message when you first open it You say “I agree” and then you hit “Purchase” and that’ll create the virtual machine That’s important when that is being created, you want to leave it alone because if you connect to it before it is completely finished, you can mess up the creation So, you have to wait until it’s completely done and the way to do that is to first of all, you enter that link, and that link will be provided to you from your virtual machines node inside of your Azure Portal So you can copy it from there and then you enter this Over here, there is a “View Installation Status”, when you click that, it’ll show you exactly all the steps that are taken to create this virtual machine So, obviously it starts, then it does a bunch of things, it refreshes every few minutes So it’s quite annoying to look at this for an extended amount of time So you see all these steps that it does Then over here, there is a step to pull the image and I have created this one based on an insider build so that is that guy over there 20977 and it is a bunch of other stuff At some point, it says, Containers setup complete and it says, Desktop setup complete and then afterwards, it’s going to go into Windows Update and you can see that between the start and the end, when it says Windows updates installed, when you see this message, that means it’s finished Until you see that message, it’s not finished yet, you need to leave it alone So, from the start– So this started at 10:34 PM, it’s a late night for me and it ended at 11: 45 So we’ll bet over an hour You need to wait until you see this message and then when that’s done, you can go in here and then you can hit “Connect ” and then you RDP in here and that’s when you see these two Internet Explorer windows So this is the landing page, we don’t need that right now Oh, one more thing, this is the AL extension for Visual Studio Code So, if something gets messed up in that, you can download it from there and reinstall it if you wish to This is always linked to the version of the Docker container that you create So this guy, that version and this version should always work together So those are important pieces We’ll go into the launch.json later on in this video The other parts, the other link is the Developer Preview Updates So this shows you which update it is I am working on, actually I’m not working on a Nav Developer Preview, I’m working on a specified template, but it’s used by the same template Actually after April 2, the Build will become public and you can get it through this link So, bcsandbox is the link that used to create that template after Business Central is released on April 2 So, by the time you see this video, this will probably already be in effect So, we don’t need these two Let me show you around the virtual machine So you’ll notice that a number of these short cuts have the word NAV Server NAV Server is the name of the Docker container So the Docker container that includes the service to your inside of it called NAV Inside that Docker container, the service tier is called NAV but the Docker container itself is called NAV Server So, the parts of these Docker containers, you’ll see we have a Web Client, we have a Windows Client, we have a CSIDE, and then we have some Command prompt, a PowerShell prompt Then in addition to those, we have Nav Container Helper, access to PowerShell ISE When you open this, the PowerShell ISE, the Nav Container Helper is already preloaded in there so you can start using those command-lets immediately and this is Visual Studio Code I will look into that a little bit later So when you double click on Nav Container Helper,

this is a command prompt When this loads, you can see all the available command-lets So, these are some Container info functions, some Container handling functions, some Object handling functions, some App handling functions So, when you do development on NAV Server, you should also have another Container for testing Inside the testing Container, you actually deploy your app using PowerShell command-lets and that’s where you will use the Nav Container Helper functions So, this is what those are Let me show you the shared folder So, open Windows Explorer One thing that you’ll need to do is go to “View” and make hidden items visible I always like to restart this so you when double click the “C drive”, you’ll see “Program data”, inside of program data you have the “Nav Container Helper Folder”, inside of there you see the “License” So, one tip is if something went wrong with your license download when the virtual machine is created with your license, you can just copy the license in here you call it “License.flf”, and then you run the “Replace NAV Server Container” command and that rebuilds that NAV Server Container based on the image that’s on the computer Inside the NavContainerHelper there’s an extensions folder and inside the extensions folder you have a folder called NAV Server and NAV Server corresponds with the NAV Server Container for which those shortcuts are made So, when you destroy the NAV Server Container, it will also destroy the folder NAV Server So, if there are any files that you need to save as part of your work inside the NAV Server Container, you need to save it outside of that folder So what I usually do is, I create a folder in the Nav Container Helper folder So, for instance I was doing a migrations, so I would create a folder in there that’s where I put my object files and that’s where I pull them from when I do object manipulation inside of the container So, if you want to see an example of that, take a look at the migrate your IP to AL video and in there I explain some of that work and so be going to say a little bit more detail and that’ll give you a good example of how to use that folder in a real life example So, let’s get back to the presentation We’re done with this part of the demo Next, we are going to take a look at Visual Studio Code also known as VSCode So, what is Visual Studio Code Visual Studio Code or VSCode is a lightweight, multi-platform source code editor It’s platform independent although we have three versions at the moment One is for Windows, one is for Mac OS and one is for Linux There is built-in support for JavaScript and TypeScript and node.js The key strength and this is the real important and powerful thing about VSCode is that it is also built on a model of extensibility through a built-in API So, the tool itself is really lightweight There is really not much to it, so it’s not like a six gigabyte download and a two hour installation process You install it, it’s a tiny little thing and you add extensions to the tool to serve your purpose So, there is a rich ecosystem of extensions So, this goes into languages like C++, and C# and Python and PHP and obviously, the AL language that we use There’s a bunch of runtimes like .NET or Unity There’s utilities like debuggers, code analysis, there are themes and snippets and of course the thing that we’ll be using mostly, the AL Language Extension for Dynamics NAV and Dynamics 365 Business Central So, let’s go into the visual studio code anatomy There are a few really simple parts about VSCode The first is the menu and as you can see there are just six selections on menu There’s not a whole heck of a lot to the menu The next part is the “Activity bar”, even though there’s lots of room for more, there are only five of them The top one is where you look at the workspace,

all the files in the workspace The second one is for search where you can look for files and things The third one is the Git Integration So, in there you can see the modified objects and that sort of stuff The second to last is the debug window, the debug area that’s where you go to look at the immediate variables as you’re stepping through the code and the final piece of the activity bar is the collection of extensions that you have installed in your VSCode The next is the status bar in its dormant way Status it’s blue, when it’s working it can become a different color like yellow or red or orange or whatever It really depends on the extension that is active at the moment that you’re doing something, but the status bar is like a dynamic thing with which you can interact with VSCode The big window is the text editor and this is really what it is It’s kind of like a notepad, kind of text editor tool and then the extension that you are using is interpreting the text And so, I’ll show you in a demo a little bit later on how you can type for instance power shell code into the text editor, but VSCode won’t recognize it unless you have something that interprets that for you And so, that’s the power of VSCode, where those extensions actually add the functionality that you need for the work that you’re doing Another important piece is the Command Palette This is one of the main ways that you’ll interact with the system You’ll see it’s like a text box with a greater than symbol Greater than symbol signifies whether you’re in a Command Palette or in the file search comman-line interface Visual Studio Code operates on individual files in workspaces, and so it opens single files for editing So, every time that you click on a file it opens that file for editing and you go into the editor and start typing And those files live in a folder, and so each file is always in a specific language mode and that’s detected from the file extension So, the file extension is tied to the extension that you have in VSCode and based on that interaction, it recognizes the language mode of that file and it’ll start interpreting the code that you have Then, you know, whenever you are working with files, you’re also working with folders And so the folders, the main folders are also referred to as workspaces So, when you open a workspace that’s the main root folder where all the files of your project are contained and that’s your workspace The folder that’s opened is referred to as the workspace root So, when you have VSCode installed locally, it also comes with a context menu So, when you right click on a folder you’ll see a selection to open with VSCode A workspace can also be mapped to a source code repository The command palette is very important Menus only contain part of the basic functionality and so a lot of it is done by way of the command pallete and shortcut keys So, there are no toolbars or icons or ribbons For instance, Visual Studio has like six and a half million ribbons and icons and toolbars, and it’s extremely frustrating for a beginner to find your way around it, very overwhelming VSCode is almost the opposite, where there is nothing unless you put an extension in place that adds those commands to the command pallete So, that’s how you interact with the two So the command palette is the primary means of interacting with VSCode There is a shortcut key to open the command pallete which is “Control + Shift + P”, which gives you quick keyboard-based access to all the functionality, basic and extensions So, as soon as you add an extension and you open the command pallete, you’ll see that there are additional commands in the command palletes that were added as a result of you installing one of those extensions The other part is “Control + P” So, you have “Control + Shift + P” and “Control + P”

“Control + Shift + P” opens the command pallete with that little greater than symbol When you do a “Control + P”, the same text box opens but it does not have that greater than That’s where you have file access and CLI access to supported functionality Another thing that makes VSCode very powerful are configuration settings So, anytime you make a change to a configuration, it is actually done through a configuration file So whenever you change a setting, that’s saved to a configuration file And so, you don’t have to browse through your whole application to see what it is that you’ve done You can actually just open the configuration file and you can see everything that you’ve changed It doesn’t show all the default settings but we’ll go into the configuration files and I’ll show you where you can find everything The configuration language is JSON JSON stands for JavaScript Object Notation and it’s a key value pair based text files and so it’s very easy to understand when you see one It’s almost self-explanatory It’s just a pair of values One is a key and one is a value and they link together And they are stored in a file with an extension JSON, and, based on that, it recognizes it as a configuration So, the way to go into the configuration, you do “Control + Shift + P”, which is the command pallete, you go to “Preferences” or you go to “File”, “Preferences” so the configuration is one of the few things that are actually on a menu So, let’s take a look at some of the most commonly used configuration file You’ll see a few versions of settings.json One is the user setting and one is the work space setting So, the configuration for a particular user applies to the entire application and it overrides default application settings and behavior And then you can also have a settings.json for the workspace itself Then we have language snippets Snippets are really cool Very useful. I will show you a ton of snippets as we go through these videos and you can actually change them You can add snippets yourself They are available per language So, there is an al.json where the snippets for AL are stored And then, the other part that’s really important is the keybindings.json as NAV developers, you used the certain keys You could, if you wanted to, go into keybindings.json and actually assign shortcut keys to actions that you’re used to in Seaside I wouldn’t recommend that, I would just recommend getting used to the way that VSCode does it and use the shortcut keys that are available in there But, if you wanted to, you can change them Source Code Control Integration is based on Git So, most common commands are available within VSCode The Git part supports Git repositories and providers So, you can have a repo and GitHub You can have repo in BitBucket or a Visual Studio team services You can have your own TFS set up to hold Git Repos You can have others installed as well So, you can see it in activity bar, those are those little things on the left hand side, and the status bar at the bottom Once you’re in there, and you’re doing a Commit, it’ll show you when you’re connected to a repo or remote repo that you need check sum in So, you can do branching and tagging Gutter indicators when you’re in compare mode You can see on the right hand side the gutter, so you can click on the gutter it will jump right to those changes You can compare changes, merge conflicts You can initialize Git repositories Everything’s available. So, then we get to the code snippets Each language provides a default language snippets and it’s all contained in where you have language.json, and that language file contains all the snippets And, of course, you can add your own snippets per language The way to insert a snippet, you do “Control + Shift + P”, which opens the command palette, you hit “Insert snippets”, you select from a list or you start typing the snippet name And the usual way to do this is that snippets for a particular language will have a common prefix And so for the AL language, as I’ll show you later on, the way to access the snippets for AL is by starting with a T, so you when you need to create a table,

for instance, you do T table and that opens the list of snippets for tables You can also create snippets So you do “Control + Shift + P”, which opens the command palette, you go to “Preferences”, open “User Snippets”, you select from a list, and then in there you can actually create snippets yourself And there are, for instance, extensions for VSCode that are created to help you create new snippets And so there’s a whole way for configuring those snippets and you can get really fancy with those kinds of things so, if you’re interested, that’s where you should go Okay. So, all of this that I’ve talked about, let me open the VM and let me show you what it looks like We’re back in the virtual machine So, let’s open visual studio code and see what we can find in there As it’s opening up, you can see that it immediately checks for Git and, because it’s not found, it asks for installing it or configuring it Let’s ignore this message for a little bit and let’s just take a look at the elements of Visual Studio Code So, at the top we have our menu selections There’s not a lot of them at this point We don’t have any ribbons or icons or buttons. No clutter And then we have, on the left hand side, the Activity Bar, where we have the top selection is the Explorer, which is a view into the current workspace and the files that are within that workspace It’s asking for opening a folder because we don’t have an actual workspace open at this point, which will come later The second is a search capability where you can search for keywords or anything in all the files inside of your workspace The third part is the Source Control and this needs to be set up So, first of all we need to install Git, then we have to set Git up, and then we have to do some repository work. We’re going to do that later The fourth piece is the Debugger and inside the debugger you’ll see the familiar elements like the variables and the watches and the call stack As soon as you start debugging this you can work through the code step by step And then, finally, we have the Extensions, and at this point can see that the only extension that we have installed is the AL Language, which was installed by the template for the Azure VM So, this is the only thing that we have in Visual Studio Code at this point So, the first thing we’re going to do is create a file So, for creating a file we have “Control + N” Or we can go to the “File” menu and select “New” This creates a new file and at this point all we have is a plain text file So, we can see at the bottom down here the language mode is plain text By the way I’m looking at the status bar at this point The status bar gives us ways to interact with this file So the status bar itself provides for very important functionality So I’m going to paste in some PowerShell And this PowerShell as you can see is completely white There is no syntax highlighting, so Visual Studio Code obviously is not recognizing any of this The language mode is still plain text So let’s see what we can do with that And for that we have the command palette To get access to the command palette you press “Control + shift + P” at the same time which opens up the command palette So in here we’re going to try to do is change the language modes So let’s type in, start typing a command So let’s type in change, and so you can see a bunch of things that have the word change in it Let’s see what happens if I type in the word language There’s a bunch of them. Let’s see what happens if I do CLM You can see that I have three letters C and L and M and it just pops in a suggestion of change language mode So the command palette is very smart It’s not just you know precise typing, you can also look for these commands by abbreviating them So let’s select this and then let’s type in PowerShell So somehow it knows about PowerShell, and once I select it, once I set the language mode of this file to PowerShell, it recognizes that syntax So I have syntax highlighting now So let’s if we can make this run So let’s go to the Debug window,

and then hit the play button Soon as I hit the play button is asking me for an environment So this is about the first indication that we are missing something, and so lets escape out of this and lets close the user settings because that’s not what we’re looking for So let’s go into extensions because what we need to do is find the PowerShell extension So as you can see, the first suggestion in there is the PowerShell extension by Microsoft So let’s install this and you’ll see how quick this is It’s a very small file, there is not a lot to it PowerShell is probably already part of the system a little bit and this just exposes it to Visual Studio code Now, in order for us to actually use it, we have to reload Visual Studio Code So as you remember we have an unsaved file in here So let’s go in here and see what happens if we click on the “Reload” button Reloading actually restarts Visual Studio Code and at this point, you can see that it is enabled, it is still not found So let’s just ignore that for a bit And as you can see it also remembers the unsaved file So, Visual Studio Code is even aware of an unsaved file and even though it’s unsaved and untitled it kept its value in there So now let’s see what happens if we run this So let’s make this a little better bigger Go into the Debug window and hit “Play” So now, it knows about PowerShell and you can see down here that PowerShell has a session open right now and it’s running this PowerShell inside of that session And so we do have a process with NAV in there So now let’s take this a step further and let’s see if we can save this file as a PowerShell file So “Control + S” and then we give this a name, MyfirstPowerShell.PS1 So now we have a PS1 file, which is still recognized as a PowerShell file So I can go in here and click or press “F5” which is the same as running this So it executes the same thing only before it executed this command and now it actually executes an entire file So this is now a PowerShell script file So let’s take the PowerShell itself a little bit further because I want to show you a snippet Get process, gets the process that has a NAV in its name This might return a collection of processes and we want to loop through them So let’s see what happens if we type in for each, and IntelliSense immediately suggest a couple of things One is a foreach as an object and one is foreach as a snippet Now, one thing you may notice is that there is a squiggly red line underneath for each and I can see that there is a few problems at the bottom here So one of the problems is there is a missing opening parentheses after the key word for each This means that the real time compiler is continuously checking for the validity of the code that I’m creating So for each is not complete at this point So let’s see what happens if I create, if I use the snippet So when I select snippet, it gives me a little bit of code and it seems like there’s a placeholder and if I tap from the first into the next and I do “Shift tap” to go back, you’ll see that it’s still interacting with those placeholders, and so the snippet has these capabilities that will help me be more efficient at writing code So let’s just arrow out of this and now it’s all part of my code So what I need to do is make sure that my Get process is saving the processes into a collection and I have to do something with that collection inside of mine for each loop So let me just paste this code in here Let me just paste this code in here and let’s run this by hitting “F5” So it’s essentially doing the same thing because we only had one process with NAV It didn’t do much because the collection only had one element

But as you can see it has the snippets I showed you the snippet, I showed you the file extension and the file is now green I just wanted to show you the snippets and the language mode and extensions how that works So let’s get back to the presentation Next section is the introduction to the AL Language extension So part of that topic, is I’ll show you the AL Language extension real quick We’ll create a demo workspace We’ll talk about configuring the workspace We’ll talk a little bit about some of the extension commands So the AL Language extension was created first of all to create objects for Dynamics and NAV and 365 Business Central You use AL Language extension essentially to write AL code obviously, inside of those objects You have syntax highlighting, there is IntelliSense I already showed you a little bit about the IntelliSense and that also works for AL We have compilation errors and warning in real time So as you’re writing code you get these error messages in the problems window immediately and so sometimes it can be a little bit annoying because you know it’s faster then you can write the code, but at the same time it’s also really handy because you don’t have to save the objects before you can see whether there’s an arrow or not So that list is really handy because it’s interactive as well So we’ll go through all that I’ll show you everything, and how to interact with that part Visual Studio, the AL Language extension is also used to deploy too a service tier in Dynamics NAV or Dynamics 365 Business Central There’s a functionality ought to automate the creation of workspaces and we will walk through those steps real quick in the next demo The first thing I wanted to mention is that the AL Language extension is under continuous construction, although I have to say under-construction sounds really bad It’s a very stable product at this point but Microsoft is rapidly adding new features and improving existing features So it’s sometimes a little overwhelming at how fast they are improving the tool but the tool the way that it is today is so much better than it was just two or three months ago As someone who’s part of the community, I want to give a shout out to this one as well and promote the GitHub, the Microsoft AL repository on GitHub The community can participate by testing and providing feedback Everybody in the Dev team at Microsoft is watching this repository and I have seen issues be solved within a matter of hours So this is not just for issues with AL Language Extension This is also where you can go for submitting new requests for events and that sort of thing Currently, AL extension only targets extension development There are people that want to speculate about what else is supposed to be doing, but currently at this point in time the only thing that it’s used for is extension development for Dynamics NAV and Dynamics 365 Business Central The AL Language extension has a command to generate the extension workspace folder structure and the starting files that are part of that And to create a demo workspace you hit “Control + shift + P” which opens the command palette and then you enter AL go And when you run this, it creates a default workspace which contains the configuration files, plus an example AL file, as a Hello World example So let’s go into the VM and create a demo workspace We’re in Visual Studio code and we are going to create a new workspace for an AL project So first of all we do “Control shift P” to open the command palette and then we look for the command AL go And when we hit this, it’s asking for a folder and let’s call this Demo Project The first question that you get is whether you want to go into a Cloud Sandbox or your own server Since we are in a VM and we’re in a controlled environment,

we don’t want to go into a Cloud Sandbox, we’re going to go into our own server At this point it’s asking for authentication but the configuration file goes to local host which is not going to work And so we need to do some set up before we can make this work So we’re going to “Skip” and “Escape” out of the authentication Git is still not found, so let’s ignore that message So what we see now is the AL workspace, let’s called DemoProject and inside there we have a folder called.vscode and inside of there we have a file called launch.json We have an app.json and we have When I click on that you can see that this is a page extension with an object number with a name and it extends to the Customer List The Customer List has a little squiggly line and if I click on “My Problems” it’ll show that the target page Customer List for the extension object is not found The reason why this is will become clear I also want to show you that if I go into the Documents folder, I now have folder called AL and inside of AL I have my DemoProject And if I open this and I show you Visual Studio Code at the same time you can see that the workspace for my DemoProject is actually a folder on the drive So the files in this folder are all recognized inside of the AL project And so even though this is red because there is an issue with the code it is still recognized as an AL file, see? The language mode at the bottom clearly says AL So it recognizes the object as an AL object and this is actually a fully fledged workspace for an AL project So let’s go back to the presentation Configuring any aspect of VSCode itself is done through JSON files and JSON stands for JavaScript Object Notation VSCode workspaces are also configured through JSON files and these workspace settings override user settings So you can have a setting for a particular property on a user level that’s overridden by the same setting for that property in the workspace Configuration files are supported by tooltips and IntelliSense and general overview of configuration options So you can open the user settings that shows the “Default” and you can go through the entire list and it’s searchable and it has IntelliSense and it has tooltips to see what you can do with those configuration objects An AL workspace has a number of configuration files and the two most important ones are launch.json which is the core Visual Studio Code configuration file and Visual Studio Code uses this file to control the launch process So it sets the starting object ID, it sets the User Authentication, it sets the server name all that sort of things The app.json serves the role of the NAV extension manifest file NAV or of course Dynamics 365 The settings.json obviously only exists if you have set certain properties at a workspace level, and it has the core Visual Studio Code configuration file for the workspace in particular It’s not as important as launch.json Launch.json itself when it’s placed in the VSCode folder is understood and processed by Visual Studio Code It applies to all extensions, so not just AL Language Individual extension can publish their own launch provider that define how the launch process works for the extension So there are certain parameters inside of the launch.json that are unique for that particular extension So launch.json for AL Language has AL Language specific parameters that you can set within that file So the AL Language extension uses it to configure the connection parameters for Dynamics 365 and the Dynamics NAV server The AL configuration settings in launch.json or at least some of the most important ones are the server, the HTTP URL of the server, the server instance for instance NAV, port numbers, tenants and in case the servers configure for multi-tenancy authentication specifies the type of authentication, the startup object ID is very useful for development purposes so that you don’t have to navigate to a certain page when you want to test your development

Another important property is this schemaUpdateMode which specifies how the build process behaves When you set it to “Synchronize” it retains the data between builds, when you set it to “Recreate” it rebuilds the entire solution and it destroys the data between builds In that case when you’re testing in your development you create some data, when you rebuild, you lose the data because it completely rebuilds all the tables The important settings in app.json are the name, the publisher and the version Those three are very important because when you publish something to appsource the name and the publisher are linked to your account at Microsoft and the version determines compatibility between apps, dependencies between apps And it also manages the process of upgrading the logic The ID range must be within the range of the app that you’re developing And another important feature is the translation file which enables the XLF language feature which in itself replaces the ML, the multi-language functionality that was in existence before AL extension commands are accessed from the “Command Palette” and they are all prefixed by AL And these are some of the most important commands that are available And I want to particularly mention the “Go” which is used to create a new workspace and we’ve shown that Another important one is the “Package” and the “Publish” Sometimes when you’re developing, the build process doesn’t replace the “Package” file correctly and that’s always handy to have a specific command to just do the “Package” without actually running it You can also “Publish” without the debugger or including the debugger so when you hit “F5” that runs the debugger, if you hit “Ctrl+F5” it runs the project without the debugger Download Source Code and Download Symbols are important for setting references within the workspace and we’re going to take a look at that now We’re going to take a look at Configuration files So there’s one thing I’d like to do is zoom in, so “Ctrl+” zooms this in and this is important because I want to show you something So lets go to “Shift+Ctrl+B” and then we see, “Open User Settings.” You can also type if that doesn’t show up right away and “Open User Settings” will show up So let me maximize this for a second You can already see on the right hand side that there is a user setting and a workspace setting So you can click on “Workspace setting” There’s nothing in there to override the user settings but in my user settings I have the zoom level set to one This is a user setting which means that they apply to my user If I open another workspace, it’ll also be at zoom level one Now let’s say we want to change something else around So let’s take a look at the theme The default theme for Visual Studio Code is this dark black background and I’ve seen people wanting to change their environment to a light background like what it used to be in C/SIDE So you can actually go into Search setting and look for “Theme.” And you will see all the options that have the word “Theme” in it and it limits the settings that are available So on the left hand side you have your “Default” settings and we’ll see over here we have “Workbench.Color” theme If we go in here and I want to say “Edit” it will give me a list of all the options, so the default’s dark, maybe there’s a default light as well So as soon as I click something, you’ll see on the right hand side it added another option to the JSON file See the JSON files with a curly brace and then it has a key This is the key, the “window.zoomlevel” and a value pair So key value pair and then we have a comma and then it goes into the next one And you’ve noticed that as soon as I changed this to a different value, it changed it immediately for the entire workspace or the user settings Now I can select the value “Default Light” and remove this and do “Ctrl+Space” which forces IntelliSense to give me all the options that are available at that point So let’s go and select “Abyss” and as soon as I hit “Save” “Ctrl+S” it saves it and it immediately applies that theme to my setting

Now let’s say I don’t like this at all, so I’m going to just “Remove” and “Save” it and that reverts it right back to the default Dark+level Now I can also apply a setting to the workspace and that would then override the setting for the user So user settings says I have zoom level one, I could set the workspace setting for a particular workspace to zoom level three So for instance if I know that I’m going to demo a particular workspace in a really big room and the screen is really far away from the people in the back, I could zoom in a little bit more just for that workspace without it affecting my main development experience So let’s close the workspace settings Now let’s go into app.json Now app.json is the manifest file and so in here we set the publisher So that’s my work for Cloud Ready. Software and my DemoProject is on some demo exclamation point That’s good enough for me. So when I save this, another important value is this ID You don’t want to change this as soon as you create a workspace for an app You need to keep this ID the same because if you change it you’re going to get problems when you do an update or an upgrade to your app So now let’s take a look at launch.json Now this is where the server settings are set So now, let’s take a look at the Landing Page If you remember, we briefly looked at the Landing Page for this particular container, and there was a set of setting for launch.jason So, here it says launch.jason And now we have some values now we copy these values and I’ll see if I can them in the screen at the same time And you’ll see that there are corresponding values here so, Server, serverInstance It also specifies a tenant and authentication So, what I’d usually just do is I “Select” these three lines and I “Paste” those values in there and as soon as I hit “Save” now my launch.jason, actually looks at the server that’s installed on this system That’s it. Let’s go back to the presentation So now, we have a configured workspace Let’s talk about the AL Language itself There’s a few pieces to this puzzle So, let’s talk about, Understanding AL,.al files, Symbols, Object types and Additional features In order for us to Understand AL, we have to acknowledge that it’s not the same as C/AL AL is very similar to NAV text format So, when you look at page and table and x amount ports and all those object types that are familiar to you, the representation of a text format object export is very similar to what you see in AL So as an NAV developer, AL objects will make sense very quickly, you will recognize almost everything There are some very important distinctions AL omits most IDs except for object IDs and Field IDs, but controls don’t have IDs anymore So that’s very nice You have to pay attention to names It’s not sensitive to regional settings If you’ve seen the video about migrating IP, I went into the differences between the syntax, the old syntax and the new syntax where date format is different, no longer bound by regional settings Time is different Booleans are now true or false Not yes no. So, that’s that Boolean constants are true/false instead of yes/no I just said that or ja/nee or oui/non Naming conflicts are checked at compile time So, as you’re typing a name about a nanosecond after you do this it will check to see if that name already exists and it will yell at you in the problems Window if you use a name that’s already in use Certain key words are changed AL introduces more object and variable types like these replacements for.Net variables for instance There is no.Net interop

Speaking of which for Dynamics 365 at least AL does not use UPPERCASE, but cases never autocorrected So, when you select something from Intellisense, it puts the right values in there But if you don’t have the case correct while you are typing and you don’t accept Intellisense, it’s not going to autocorrect your case AL is Unicode. So, if you want you can program in Chinese, I wouldn’t do that because I don’t speak Chinese but if you wanted to you could No documentation triggers, so the documentation trigger was removed You could put comments in any object at any time just but to forward slashes in there and you can put comment in there AL is not a replacement for C/AL It’s a work in progress Again I don’t really like using the word in project progress because it kind of implies that it’s not finished yet It is finished. It’s a stable product It’s really a fantastic tool in my opinion, but they are constantly adding new features and improving existing features So, it may change There might be new features They might drop old features just like any tool We’ve seen that before where, you know, there were some changes and we have to deal with changes and changes are good So, even syntax can change For instance, at some point, function calls had semi colons at the end Those are now optional, so you can leave them out if you want to And also AL currently only supports Extensions Development I’ve said this before I think in this video There are some people that like to speculate about where AL is going next I don’t like to do that until they come out and actually show what it’s supposed to do For now I’m happy doing Extensions And I think it’s doing a great job at that If you want to check this link out, there are some comparisons between the old developer tools and the new developer tools So, let’s go into AL syntax When we talk about the code, the programming, the AL syntax is the same as C/AL So, before when I was talking about AL I was talking about AL objects in general like the greater object that in its entirety The syntax of the code itself is the same as C/AL So, all C/AL code that is ported from C side into Visual Studio Code should compile except for any unsupported data types So, all C/AL keywords are still present in AL So, as you are programming code units in Visual Studio Code, all you do is just program C/AL code the way that you’ve been using it You have to get used to where the variables are and that sort of thing, but writing the programming code is exactly the same as AL So, the only differences are C/AL always auto-capitalizes as keywords, auto-correct capitalization on function calls on variables, AL never does that Intellisense suggests PascalCase on all AL built-in functions and keywords All AL code must be placed in file AL files can go anywhere in the workspace folder hierarchy So, you can have a main workspace folder with a hierarchy that goes 10 folders deep and you put an AL file all the way in the 10th level, it will still recognize that there’s an AL file One AL file may contain more than one object You can have a single AL file for your entire app, but that’s not recommended The best practice is to use one file per object, makes it so much easier, also a source code control And each AL workspace must contain at least one AL file, otherwise it’s not recognized as an AL workspace AL files may be empty but must be present AL syntax highlighting only works in AL files So, you want AL language extension to work You have to file in order for that to work So, let’s go into the VM and let’s create file So, we’re back in Visual Studio Code and we’re going to create a new file We’ve already done control N we’ve already done

file and then new file the next way to create a new file This is the way that I like to do it It is the click of a “New File” button and that way you can immediately give it a name So, let’s call this “” So, because this is an AL file, the bottom you see the language mode is immediately switched to AL, and our object is going to be a codeunit So, we are going to create a codeunit with number of 50,100 We’re going to call it, “Show Today” “Enter”, “{“, “Enter” See how when I typed the “{“, let’s see that again When I type curly brace open, watch what happened It immediately put a curly brace close underneath it or behind it Now, if I type “}”, it doesn’t put another one in there, it knows that that’s what I want to do and it keeps track of opening and closing curly braces So, when your cursor is in the middle, you hit “Enter”, it aligns it, it indents the code right where it’s supposed to be So this is it This is how easy it is to create a code in it So, I have a fully functioning code units with no problems in the code No red squiggly lines The only problem we still have is this target page customer list for the extension object is not found and it’s a problem we’ll solve a little bit later One other thing I wanted to show is IntelliSense So, right now I’m in between curly braces If I do, “Control” “Space”, it gives me certain number of things that I can do here So, this is the context in which IntelliSense shows me the options that are available for me If I go outside the curly brace and I do “Control” “Space”, now I get completely different options So, now I’m outside of the definition of the code in an object and now I can create different object types So, I can create a table or a table extension or anything like that Seeing so, I go back into the curly brace, I do, “Control” “Space”, it gives me different options So, lets create a trigger Now, if I just start typing “Trigger”, it will show me either trigger or the trigger snippet Let’s just accept trigger and let’s do “Space” and then let’s “Control” “Space” again And so, now I get a number of selections again Let’s pick “OnRun” So now I have OnRun And see how it puts parentheses in there immediately And now it says, “AL Syntax Error” I’m expecting a “Begin”, and see how when I was done typing “Begin”, it put an “End” behind their immediately So, if I do “Enter”, it indents it immediately and all the compile issues are gone So, I have a fully functioning code unit, with a fully formatted trigger, with a “Begin” and an “End” and notice that there is no semi-colon at the end of the function call Now, what we’re going to do with this trigger is, we’re going to display a message that says “Today Is”, and then it provides a day And so, for this, we need a variable that we’re going to store a date value in And so, what we need to do is, we need to create a variable section So, that goes between the “Trigger Declaration” and the Begin” So, I do “Control” “Space” and it’ll tell me, “Hey you can do var”. And let’s do var Let’s call this variable, “Day” “:” and let’s do “Control” “Space” Now you can see that these data types are very familiar So, you have a “Boolean”, you have a character code, a code unit et cetera These are all familiar looking data types And some of them maybe not so familiar like “HttpClient”, and “Headers”, and “RequestMessages”, that sort of thing But you’ll see that, if I type in “Date”, that’s a recognizable data type

So, now I have my variable So, now let’s program the value for “Day” We’re going to set day and you’ll see that IntelliSense immediately displays my variable as a valid option So, I’m selecting it Now, I’m going to set that value to the value “Today” So, you will see that “Today” still exists or it’s not capitalized Then we’re going to compose a message And as soon as I do a single quote, the system puts another single quote right after it If I type another single quote, it’s just going to skip right after it So it understands the context in which I’m doing quotes as well So, the message is, “Today is”, let’s put a placeholder in there That’s really it. The next topic is, Symbols The AL language extension understands AL itself, but it does not understand the underlying application model Available objects, properties, methods, inside the application itself is not understood by the AL language AL language understands the syntax, it understands what type of objects you can create, it understands the properties that are available inside of those objects It does not understand the entities, or the methods, or those types of things inside the system And the same happens really with the C/AL Code that compiled in a localization may not compile in W1 So, you could take the localized objects out of a U.S. database and put them into a UK database and those objects would not all compile because it depended on modifications based on standard objects as well as modifications that were new to the system And so, in a similar way, you have to have that reference in order for the system to make sense So, the AL language itself makes no assumptions about where stuff is You have to tell it where to go And so, the AL language uses symbols to understand that application model itself And the symbols provides a list of available objects and their members It allows the AL language to remain strong typed So, you have variables of a certain type and you can reference those methods and attributes directly from those variables And so, to reference an objects from AL code, it must be present in either symbols or in another AL file So, what you saw in the Hello World example was that it didn’t know about the customer list because there is not a reference to that customer list inside of that workspace So, the symbol comes in a package and those packages are files And so, extension, the extension file itself, is actually the symbols package for the code that you’re writing So, when you create a new project, a new workspace, you point it to a certain service tier and that service tier is going to provide the symbols for your project So, essentially, symbol packages are nothing but other extensions And so, as a note, any app file that can be found on the packages path is loaded as a simple package and it’s objects are available to the AL compiler So, inside of the workspace there is a setting that says, “Hey, your app package files are going to be in so and so folder”, and then it will look in that so and so folder for the symbols that will be used in your code So, how do you make those symbols available? Well, to make symbols available to VSCode, you can do it in three ways One is manually copy the symbols file into the workspace So, literally by copying the file from a central location into the workspace folder Second is to download the symbols for the workspace from the service tier, or you can have a central repository of symbols for all workspaces Keep in mind that the symbols can be shared between workspaces So, you could have a centralized location

set up as the “App Packages” folder, and it will read it from that location and that location can be shared between other workspace itself So, to configure symbols, there’s a setting in your settings, “.Jason File” and that’s used to configure the symbols path And the default value is the “.alpackages” folder within the context of your workspace So, regardless of whether the setting is configured in user settings or in workspace settings, it’s always evaluated against the current workspace path So, let’s go back to our virtual machine, and let’s configure and manage our symbols file We’re back in our virtual machine and what I’ve done is, I’ve closed Visual Studio code so that I could reload it I want to see if I can get the “Symbols Are Missing” error message on the screen because I didn’t see it before There it is. So, we did get the “Git Not Found” message Let’s ignore that again. And now you see “Symbols Are Missing” with a “Download Symbols” button Now, you can go to the command palette and there is an option to download the symbols But let’s not use that Let’s just click on, “Download Symbols”, and that will issue the request to our server that we’ve configured and launched “.Jason” And now we have to authenticate against that service tier Username and password And now, it’s going to ask the service tier for the symbols and I already see that the folder has been created up here And now, we get a message that says, symbols have been downloaded So, that’s awesome news And another piece of awesome news is that the problems that we had before where the Hello World AL file had a missing reference for the customer list, now it no longer has an issue with that because the customer list is part of the reference App file which are the symbols for this product, for this project sorry, for this workspace Let me recap our situation We have an Azure Virtual Machine set up using the virtual machine template for developer preview but this one is based on one of the insider builds for our business central The container is called NAV Server which was part of the same virtual machine set up I could have also created this same NAV Server container on a local virtual machine In that case, I would have had to download the AL V6 package, that’s the AL language extension for our Visual Studio code and install that manually That would have also worked We created a AL workspace by using Control Shift P and using the AL Go command to create the workspace Inside of the workspace we have a launch dot json that points to that server We have a App dot json that has a publisher and a name and an ID We have a couple of AL objects in there I’m not going to publish this because that was not the point of this demo The next step for us is to go back to the presentation, do the recap for this video today in preparation for the development video But with all the information that I’ve shown you so far, you should be able to be all set to start developing your first extension So, let’s go back to the presentation We’re in the final stretch So, AL object types The AL language supports these object types I won’t read the whole list but the most important object types in my opinion are the extension objects So, we have tables, pages, code units et cetera Those are the same types of objects that are available, used to be available in Seaside

The thing that makes extentions so powerful is that you can piggyback on existing objects Of course, by using event based architecture and by subscribing to events that are published in the Base App The other part that is really important are the extensions on top of existing tables and extensions on top of existing pages And so table extensions and page extensions, I think are the most crucial Object Types that are available in the AL language What that really means is that in AL it is impossible to customize existing objects So, the thing that we are used to as NAV developers is that we could just get into the Base App, we had full access to everything in the Base App and we’re just used to modifying everything that we wanted In AL you cannot touch any of that And so, instead of that, you can provide extension objects for tables and pages And these are essentially modification files, so if you’ve watched the video about migrating your IP to AL, there’s a whole section about running some scripts to translate and convert objects from C/SIDE into AL, and part of that was to create Delta files And if you’ve ever looked at a Delta file, it will be very similar to what you see in the extension objects So, a table extension is really a Delta file for a table A page extension is really a Delta file for an existing page object The only difference is that these page extension and table extensions have much more functionality than Delta So, we used to be limited by the things that we could do to existing objects Some changes were allowed, some changes were not allowed, and you always had to be very careful with what you were doing And so, in these extension objects a lot of things are possible And so, the functionality is just so much greater than Delta files with a much smaller conflict surface than Deltas because the objects are specifically created to extend those existing objects So, some other features are in AL, in Visual Studio code, we have Snippets, programming REST API’s are made much easier by using a bunch of new types of variables for XML, for JSON, for DotNet replacements And I can’t wait to show you all of that in the next video about actually developing an extension for the AL language So, I’m going to leave it at that for this video If you want to learn more, please go to this link in your screen aka dot msBusinessCentralApps and there should be plenty of access points in there for these Azure VM templates, for getting access to documentation, for all your resources go to this link That leaves me with nothing else to say, but thank you so much for your time, for listening to me ramble on about this super exciting topic near and dear to my heart, and I hope you have a wonderful day