Best practices in Visual Studio Code development for Dynamics 365 Business Central
Hello. And welcome if you probably know by now visual studio code, was chosen as the tool for app development, for. Microsoft, Dynamics 365. Business, central in. This video I will show you around this great tool and I will discuss some best practices, some awesome tips and some, great tricks all of which can make your life a whole lot easier as, an al developer, I want. To take this opportunity, to thank Eric routers, also known as Waldo was, one of my fellow partners, at CRS, for. Providing the content, for this video this, is really his video I'm just presenting the material my. Name is Daniel Ramos WAN and I am a partner with cloud ready software, one, of the ISV development, centers that can help you with just about anything, related to Microsoft, Dynamics, 365. Business, central. We. Have four objectives for, this video, first, we will go into some of the main ways that you can configure vs code and how, you can customize this tool exactly, to your own specifications. Next. We'll look at some of the extensions for vs code that you can use to make your life a lot easier and much more productive, in the. Third section we, will cover some, editing tricks that you can apply to your daily work some. Of these are really cool. When. We look at a description, of Visual Studio code, this one is from Wikipedia we. See that vs code is quite an interesting tool, first. Of all it's multi-platform. Which, means that you can use it in Windows in Mac OS and even, in Linux it. Includes, all the bells and whistles that you would expect from a mature. Development. Environment, but, it is still a lightweight, program, the, great strengths, are, definitely, the fact that it is so customizable through. Extensive configuration. Capabilities, and. An ever-growing library, of extensions, in, a. Recent survey it was even ranked as one of the most popular, development, environments, I'm not really surprised, by that because in the, short time that I've used it about a year I've come to really liked working with this tool and, the fact that Microsoft chose, v/s code as the development tool for business central is, not an accident. Let's. First give you a brief overview of the anatomy of es code and, I want to mention a few other videos that, also go much deeper into this topic one. Is called setting up vs code for dynamics 365. Business Central and another. Is a two-part video series about, development, in vs code for Business Central. First. We have the menu the, menu is, relatively. Summarized. There are not a lot of. Selections. On the menu this, is on, purpose, by design we also don't have a ribbon with icons. So there are no toolbars, or anything like that. Then. On the left hand side we have the activity bar with, a couple of ways to interact with the system the, most important, parts here are the Explorer get, integration. And of course the, debugger and the. Extensions, library. The. Status bar is an important, tool in BS code depending. On the extension, that is in use at the time of editing the. Buttons, on the status, bar will change and, the color will change based on the status, of what you're doing and so there's a lot of different, ways that you can interact with the extensions, based on what happens on the, status bar the, middle, part is the text editor and this. Is really what v/s code is it's a text. Editor, that has expanded, capabilities, based on the extensions, that are installed so, for instance if you open, a powershell. File. If. You have the powershell, extension. Installed, it'll, recognize the, powershell, in there and it, just you know you're just editing, the text file immediately it just interprets. The, content. Of that text file, based, on the extension, in vs code and then. Finally, the command palette is one of the ways that you interact, with the system this, is a command. Line interface based. On also. The extensions. That are installed. So. The first piece, that, we're, going to look at is source. Control management so. Because. We will be using a completely, useless but, very descriptive, demo app let, me start by giving you a few tips regarding, source control, because, we'll be using this integration to. Get to our demo app on github, so know, that there is also a, much better video, on, source control, in this video series called, source code management for, Dynamics 365. Business central and this, section in this video just, covers some introductory, topics. The. Reason why we have source control is easy it, lets you see who, did what when, and hopefully why. BS.
Code Comes with an integrated, support, for git but. Other sem provides, also are, supported, like those that you see on the slide and the, support is being added through the means, of vs code extension, so if you want to have a. Mercurial. Integration. Into, your visual studio code you would have to install, and configure a, mercurial. Extension. For vs code for, al development, it, makes a lot of sense for us to use, get together with VST s you. Can have your repo, on any gits provider, but, the STS also provides that capability, the. Thing is though before you can start using the git integration, you, will first have to install, git and set, it up properly. When. Visual, studio code opens, it takes forget as, the first step and if, it's not installed yet you will get a message to say hey it's not installed you want to download it you. Can also go to get dot edge get. -, SCM, comm, and. Download, it straight from there and it'll recognize it. Next. You'll need to configure it by identifying. Yourself so you need to set the email and the name in. Git, configuration. Because. It. Needs to know about this because for every commit it needs to be able to identify who did it so. After, a kit is installed. Git is available, and the commands that are available in vs code are also working and, so next would be to start working on a workspace or a project, which, means either, you create a new project locally, or you clone an already, existing project. So. There are two ways to initialize. A local, repository. You, can ischl eyes the local repository, from with NBS code and then push, it into a remote, repository this. Is quite complex, and the, easy thing, to do is to just go to the, existing, remote. Repository. Create. The repo there and then copy the clone, link from there so every gets a provider. Will. Give you a way to, clone. A repo, that's on there so the repo that you create on github, for instance can. Be completely, empty but, it provides you with a link to clone. It locally, it's a much. Easier way to get. Started then initializing. The repo locally, and then, pushing it out to the. Remote. Let's. Go over some important. Gets terminology. That you need to know about in. Terms, of source code management and, get the. First term is repository. Essentially. A repository, is a project folder that. Contains all, the files that belong to that individual. Project, the. Remote is the, remotes version. Of that project that's hosted, on a remote server and what, you do is you clone the remote to, make, a local copy of that remote repository. That, allows you to work offline so that's the main key for git is there, is a central. Repository and. As, a decentralized. Developer. You create a local copy of that remote, repository.
And That's, called your logo clone. Push. And pull is the process, of taking. A committed, change to the local, repository, and push, it to the remote or pulling. A remote, change, down, to your local repository. Fetching. Is similar, to pull except. It doesn't merge and so you can fetch a change from the remote and then, decide to merge that into your local, repo, manually. Later, branching. Is essentially. A copy of. The. Repo for. Various, different purposes, and there, are many theories, and. And methodologies. That prescribe, how to use branching, and that sort of thing which, we won't go into in this video. And, finally, merging. Is the, process, of taking two. Kings, sets, and. Merge them into the. Main, branch. Or any branch so if you're working on a branch two, people make a change those, change might conflict with each other you merge them together to. Figure. Out what needs to go into that branch. The. Next item, that I want to point. Out is get ignore, get. Ignore, is a file, that's described. What things. Are not. Going, to be tracked, in source, code management and. So, it's best to set this up and to think about this from the very first moment you initialize, your repository. Because, if you track a file, in, git and then you add it to, get. Ignore. The. System might not pick it up and so now you have an orphan, file in there so the way to do that is to, have. The file in your repo, then, delete, that file while, it's being tracked you, commit that change then, you add it to get ignore and then you add the file back in and that way you have it in your local repo but it's not being tracked it's not being pushed into the remote. So. For, al development, it makes sense to add the app files to, the ignore and also other. JSON, files like Settings JSON, or launch dot J's and so this, is an example of one of those get ignore files and as you can see we're. Ignoring app files because, those are generated, by the build process or when. You download symbols, and that's, something that you, need to be able to do from, different versions of service. So if I'm working on version 1 of an, app against. A certain, build, of, business. Central then. I might want, to be able to test, whether. My. Objects. Would still compile, and work against, a different version, of business, and draw and so you, don't want to track the app files King source code control, because. You. Know that's, not part. Of the development, really, itself, and, then launch die Jason, and settings days, obviously, those are local, settings, files that are not relevant for tracking. The, development. Project, in the, remote. Let's. Go into, our Azure. BM, install. Get configure. It and let's clone a. Repo. So. In my a jar BM I have, created. A. New. Container. A nav container, the. Reason for this is because in, the scripts that Waldo's provided. It. Goes into a nav, container, called def preview, and not, nav server and so, instead. Of changing all the scripts it was easier, for me to just create a nav container, that's called def preview, and now all of his scripts work so.
When. You first open visual, studio code. It'll. Check for gifts immediately, and it'll tell you I can't find get do, you want to install it and then. It provides you with a download, button so when you click on this it'll go to that website obviously. You can also go straight to this website, yourself and then click the download link there. And independent. From vs code you can install it these. Are two programs. That interact, with each other they. Are not installed, as part of it and so if it doesn't download, immediately yourself. Just, click here on the manual download link then, click run that. Will download the file and run the setup. Wizard, and. In the setup wizard you click the next button nine, times one two. Three, four, five. Nine. Install. This, takes a minute so I'm going to pause, the. Video recording. For a minute. And. When. It finished the installation, wizard. You, uncheck few release notes and finish now. Get as installed so you can close the website you can close visual studio code. And then when you reopen that, checks. Forget and it's going to find it as. You can see looking for a get its using get in a certain version, next. Is sending. Up the global variable, the global setting so, that get knows your identity. The. First one is get, config. The. Second setting. That you need to do is. That's. Not my email of course I'm not going to put my email in here so, let, me pause the video and do that real quick. And. Now my username and my user email, has been configured, for. My git integration in, BS code next. We, are going to clone a repository. And. For this we, have provided. You with a. Repository. In. Our cloud ready software github, you. Can click this link here clone. And then. It. Copies it to the clipboard and an individual, studio code hit shift ctrl P and then. You select. Get, clone and, then ask you for a repository, URL that's the one you just copied, you, paste this in here and then it asks. For a parent, file folder, so. On my C Drive I, have a folder called my demos, and, if I copy that into. Visual. Studio code. It'll. Start cloning the repository. And. That just should, just, take a few seconds. So now it's downloaded, the repository. I can, click open repository. And, that, opens the workspace, which is an AOL workspace, with. Some things missing and you'll get the error message in, a minute but. I can also take, a look at the folder itself. My. Demos now has a folder, for vs code best practices, for Al and these. Are all the files that are part of my workspace. So. We're done we have a local repository this, is a copy of the remote. This. Is a clone of the remote. Files. That we'll be looking at so let's go back to the presentation. So. Now we have our workspace, which, is the first step towards, your goal to start developing let's. Try to develop in the most efficient, way possible. What. You would be using a lot probably is the command palette. The. Command palette is your, primary means of interaction, with visual studio code to. Get it you, click on you. Press ctrl, + Shift + P at the same time like, this and. This is the command palette. You. Can also click press. Control, P which. Is file access, go to file and, this is a slightly different interface. And the difference is maybe. You've noticed ctrl, shift P, opens. This command palette and there's this greater than sign I can backspace, that out and, that goes right into the, go-to file I can type the greater than sign and that opens the command palette so, it's the same text box and it knows from the context, of what you are doing whether, you're in the command palette or in the go-to file, the. Content, in there is filtered. By the entered, letters and so, you can enter multiple letters, and. All the letters that you enter must be present in the element to, be included, in the search result, in what. Matters is the order in which you do the, character. So if I do ctrl, shift P, I would. Be able to go to for, instance change. Language. Node. That's. A command change language, mode I can. Also type. Language. And. That also shows it maybe. I don't know what. It is but I could also do. CLM. For, change language. Mode and, so that also, shows. That command in there so, this is very handy for if you are. Handy. With command-line. Interface, you. Just you know you're in in, the text editor either control shift PC, LM you, have changed language mode, maybe.
You Want to clone a repository. Cologne. There's, a command in there. And. That also puts it in there and by the way you might have noticed, when I do ctrl shift P. This. Opens, and the has the most recently. Used. Commands. Up there and so you could even clear. This clear. And. So that clears. The command history so if I do Kallang. There. It is I can do. CLM. For change language, mode I can. Do. And. That goes to a I'll go so. That's the search feature. In the, command palette. The. Same works in the file. Dialog, so ctrl P I can, do CP. And then it goes to the command palette dot, MD which is the file that we're currently looking at this is the markup. Screened. For that so, ctrl P. CP. For command palette or. So. The search. Works. In the command palette itself but also in the go-to file dialog. Next. Is the visual, studio code configurations. Everything. That is configured in visual. Studio code is entered, into. Some. JSON, file or other, so there's a user settings, dialed. Settings, dot Jason, and this, is, saved. In the roaming profile, there's, a Settings dot Jason, that's saved in the workspace if the settings, applied to the workspace itself, and so, the difference between the two is that the. User settings are configuration, settings that apply to the entire application. Regardless. Of which workspace, you have open, and it overrides, any default application. Settings and behavior so, the application, itself has default. Behavior. You, use the user settings. To. Override that behavior, similar. In the, workspace settings dot Jason, you have a workspace, level, configuration, setting that applies to a specific work space and this, overrides, user, settings, so, you might want. To think about. Certain. Settings. Like for instance the theme maybe, you, have a significance. Of the theme where maybe. For, local, stuff. You use the. Light theme and for certain, types of projects, you use the dark theme the, thing that probably. Makes. The most sense are, settings. That are specific, to the workspace such, as the code, analyzer and I'll show you the code analyzer in a few minutes. Then. We have language snippets. So. Each language has its own set of snippets. And. Those snippet files are called language. Dot, jason so for al there's, a file called al, dot jason, and in, that al dot JS and file are the user configurable. Snippets. And so those snippets apply, to the user itself, al. Jason, is then saved, in your roaming profile folder. We. Also have keyboard, shortcuts which, is saved in a JSON file called key bindings, Jason, and those, define application. Wide keyboard, shortcuts, which overrides any application. Defaults, and overrides. Any installed, key Maps and I'll I'll, show you some, example, of. That one. Of the important, things to remember is that we have a distinction, between user, settings, and workspace, settings so user, setting, which, is a file that's saved in the users roaming profile, applies. To any workspace, that the user opens and, then the workspace, settings applies, to each individual, workspace, and those settings are usually saved. Inside of a dot vs code folder. Inside, of the workspace and, I will show you in a minute what. That looks like. Snippets. And keyboard shortcuts are always user settings, as they are personal, it shouldn't depend on a certain project it means that, those files are saved in the roaming profile, and, then you can check that when you navigate to the user profile, folder. And in there you have an app data slash. Roaming, slash code, slash, user folder, and in, there would be another folder called snippets, for whether language. File is other. Settings can be specific, for a project like code analysis, settings get, specific, settings or things, like that so you, can have a git ignore file that depends, on the workspace, for, each workspace, that could be different if you want it to be different the, code analysis, depends, on what type of project you work on so if you're, working on a customer, specific. Project. Then you would have a setting, that set turns on the code analysis, for per attendant, development. If you're, working on an app source project, obviously you would have the, code analysis, for the app source cop and so, in terms of hierarchy, is clear that the user space settings, are always more important, than the user settings so, you have application. Settings that. Are overridden, by the.
User Settings, and then the workspace, settings overrides. The user settings, and that's the hierarchy, of the settings, files. This. Is an example of some settings for Al so, on the left hand side you see some user settings, where. The editor dot suggested. Selection, is set, to first so and you open. Intellisense. It always puts. The cursor at the top instead of, the most recent, ones. On the right hand side you see an example, of workspace in settings, where. We have Al dot enable, code analysis, equals true and then, we set the code cop and the pertinent, extension, cop as. The code analyzer so, that particular workspace. Is intended. To be a, project, for. A specific, customer. And so this has, particular. Implications. On what to look for in the code and, I'll. Show you in a minute what that looks like inside. A vs code. As, a matter of fact let's go take a look at that right now. So. Let's take a look at this al file which is a code, unit it's. Good unit 501, o8 configure. Code units let's. Just see, what happens if I add. A procedure. And let's use that tea procedure. Snippet. To. The. Code and then I do control space, which opens, the. Intellisense, you'll, notice that the cursor is at t-- procedure, and, so, it goes. Right to where, the, last used was and so this, is not always the most useful spot. To be in when you do in tell us it so let's take a look at the user settings. Preferences. Open. User so, user, settings. Write or. Settings. So. When you open this you have, this thing on the right hand side and you can search for settings. So let's take. A look and we. Go to the, suggested. User. Settings. Or a selection. There. We go so, editor. That suggested. Selection, by, default, is recently. Used so let's see if we can set this to first. And. When we save this and we go back to our, code. Unit we do control space and, now the cursor, is all the way at the top so, intellisense. Puts. The cursor at the first selection, rather, the most recently. Used and personally. I like this selection better because, it's predictable, you don't always, know. Well, you always know what's been, used for, the last time but, that's not always useful and so usually you want to just start at the top selection. You, know especially for, things like you. Know the object number right so if you have code. In it. It'll. Give, you the object number right away and when you do control space. It'll. Put the intellisense, right at the top rather than the last selection. So I like that much better let's. Go back to user settings so at this point I'm in user settings, right so I can also click on workspace, settings and. Right now I have disabled. The code analysis and, so when I go back into my code unit and I. See, the, problems, right if I look at the problems I don't, have any problems, that have been detected, in the workspace so far so. I would like to get some more hints about my work and so what I want to do is I want to turn on this. Code. Analysis. Functionality. And I have turned on the code cup and the, pertinent, extension, cups so and I now go back into the workspace, all of a sudden I have 12, problems. So, now I have to specify open, and close parentheses. After my publisher, so this is a function, call one. Of the things that you, need to do is. Put. Parentheses, variable. My int is unused, and method my procedures, so this, is a, variable. That you should get rid of and so now, you have, a bunch of problems, based on the code analysis tool that are. Turned on and so this is a very useful tool for you to help. You with your development. For. More information, about the code analysis tool please. Refer, to this Lincoln, or let me just open it. And. Show you what that looks like so using the code analysis tool you. Can actually add your own code to the project for you the result of the code analysis. And this is very useful because, especially. For, the. App source cop a lot, of these rules, that are, enforced. In ASP apps or scub are, also rules, that are enforced. Based on the. Checklists that are that, is in place for, submitting.
An App to app source and so before you submit an app, to app source it's always recommended to turn. On the code analysis. Tool. For app source cop and then just work your way through all the issues because they, will look at your code and they, will give back, these. Validations. Issues. And so before, you submit it is always a good idea to make sure that you comply with all the rules in the app source code the. App source cop sorry. Another. Configuration tool, is the keyboard bindings, in, which the keyboard, shortcuts, are. Specified. You, can actually go into key bindings, Jason. And change, the shirt by a shortcut, key. So for, instance nav developers, are used to do using, f3. And f4 to, insert, a line and f4, to delete a line so, we can actually go into the keyboard bindings. And set those. Shortcut. Keys so if I go to ctrl shift P. Board. Shortcuts. We. Can look, for delete. And. Delete. Line over here. In. My configure. Code, units I can, do f3f3f3. But. I also can do. To. Delete, lines. So. That's, that. File. Those, settings, by the way the workspace, settings you can see is a settings, file in the vs code, folder. On the. In. The project, itself so if I go to my demos. Best, practices, in BS code I can see a settings Jason, so you. Can actually as, you're, in your workspace right I'm looking at this al file you. Can drag this JSON, file into, your project and take a look at it that's so dear there, is the settings file that's. The same file that you're used to. That's, the workspace, file right so this is in the workspace itself, I can, also go to the user so. That's the denser. User in here I, go, into app data into. Roaming, into. Code and there. In the user folder, you, have settings, and so if I go drag, this settings file in there you, see that that is. Alright, so let me just save this and close this, if I go into control shift P and. I go to open user, settings, you can see that the comment, that I've just entered, is. Actually. Saved. So let me copy these settings. You. Want to get back to default you. Just click this file when you say delete. It's. All gone, so if I go back into user, settings, then. My. User settings, file is all empty so I can. Save. That in there and, now it's back so the same with the key bindings, you can go into the key bindings, and see what it's all, modified. In there I personally. Don't like using. F3. And f4. So. I'm just going to delete those keyboard, bindings, and be done with it. Another. Spot. That is important. All right the snippets and so you'll see there's a folder, inside that user folder, called. Snippets, which, is empty at this point but. Snippets. Is the next part, that we'll take a look at. Habits every language. In BS code provides, default language, snippets, and. Users. Can add their own snippets, for each language and so to insert, a snippet in code you, do ctrl shift P, and then you go to insert, snippet, and you select from a list you.
Can Also just, start typing the snippet, prefix, which. Initiates, intellisense. And then you can also select. From the list of snippets and then you press, ENTER to complete the insertion. So. Essentially, code, snippets, can make it very easy for developers to apply certain constructs. Or even parts of design patterns to code so. Snippets are language dependent, and configurable. So you as a user, can create your own snippets, for, all the languages, that you desire including. The language. So the, default, al, snippet. List is available, for you to edit, and, to look at only, it's. Not recommended. To make any changes, in the default, al jason, because when. You install a new version of, the al language. Extension, it'll overwrite. That, snippet. So what, you want to do is copy them from the, default. Enhance. Them improve, them the way that you want to and then save. Them in your own better, yet you should then, go. On to the, Microsoft. Al. Github. Just. Show you this the, Microsoft, Al, github. Repository. Has. A, way. For you to, put. These forth so you can actually, create. A local, copy of, this. Repository. Modify. The, snippets, so snippets, are available, in here so these are all the snippets that are part of the standard product so. You can actually go in there make modifications and, do. What's called a pull request in. Which you present, your, changes, your enhancements. Your improvement. To the Microsoft, team and every, pull request that comes in Microsoft, will look at they will make an evaluation and say well this is good this is something, that everybody, benefit, from so, they'll put it into the standard product if they, decide not to do it that's no big deal because you. Can have your own personal snippet, so if you have a snippet, that you find super, useful that, Microsoft, doesn't see the use for that. Doesn't matter because you can keep your own snippet, better yet you, can create your own visual studio, extension. And say, I have, a snippet, enhancement. Pack and provide this to the community and so, there, are lots of ways in which you can make your own experience. Much better than. What. Is in there so the interaction, between Microsoft.
User Snippets. Just. Paste, it in there and now you start modifying don't, forget to give it a different name or a different prefix, so that you can recognize which one is yours and then, if you're using this you want, to you, know try this and make some modifications, and make some enhancement, if you. Feel, like sharing it because you know not, everybody likes, sharing. These types of things if you, feel like sharing it create a pull request on, the Al github, and Microsoft. Will take a look at it and include. It into the next version, of your, product. Next. Editing. X, vs. Code comes with a various, amount of default, shortcuts, that can make your life a lot easier so let's dive into some of these editing, hacks, so. Let's open the editing, hacks dot, MD. First. Of all this is what's called a markdown, file. And. You. Can actually see. What this looks like by doing ctrl. K and then. V and this. Opens, the, file. In preview, mode on the side you. Can also open, it in. Regular. Mode and then it opens right into the. Screen. Where you're looking, at but. You. Can also. Type. In there on the left hand side and on the right hand side it shows exactly, what you're doing immediately. As, you're typing it so this is a really nice way of looking, at this. Let's. Take a look at navigation. So let's open this editing, X. And. In there you'll see a number of functions, so function, one, procedure, one procedure, two procedure, three, and in, there I have a call to the code unit editing hagseth. Method, with. A function, editing, X now I can go and do right click and do go to definition. We. Can also go. In there with your cursor in there hit f12. F12. Goes in there go to, goes to the definition. If, I want to go back so I have navigation. I do I hit, I hold down the Alt key and then I do arrow left arrow left, is back and so this is now navigating, so it, remembers, where you were so from here I can, go arrow right alt arrow right and that, takes me back to where I was. So. This is actually following, the definition, in there can, also do peak definition, which is alt f12. In. There you are you remain in the file that you're looking at right now, and it gives you some sort of a little peek into, the function, in there so, maybe. You see this and you have some sort of error so maybe you can go in there. And. Then you know you have some code in there now you can go in there f12, and now, you see that I've, actually. Edited. That code. And control-z. Works. So. Ctrl Z, you. Know undo, works. Do. Alt. Arrow back and, it goes right back. Pretty. Cool. Shift, f12, is. Finding. The references, and so now I have three. References, in there and now I can go and, click on those references, and see where. That. Editing. Hacks is being mentioned and so these. References. Are also. Shown. Up. Here see the reference up here one reference so, if I go in here. F12. In here. So the editing hacks has two references, so I can click on this. Find. Our references, 12:00, and, so I'll show all the references, where that editing hack function, is being used. Editing. Alt shift up is copy a line, so. If I go here alt. Shift. Up. It. Copies the line right underneath, all. Down, alt up, on the all down so alt up. Move. That line back. And forth. I'll. Shift, left. Shift. Left. Is. The, selection, so it expands, the selection. So. I'm in the, do editing, hex function. Call if, I do ctrl. T. It. Opens, the go-to file, with, the ashtag, and. If I enter it, goes right to that procedure, and. So it's the same as control. P. And, then hashtag, and, then you type it and, the shortcut code, is. Ctrl, T that. Goes right in there. As, we looked, at the MD, file before. Opening. The. Configuration. File. Editing. Hack. File. On, the right hand side that was. Ctrl K and then V you, can also do a markdown. Preview. By doing ctrl shift + V from, the markdown file ctrl, shift V, that. Opens, that file in preview mode immediately and, you see that, the.
Same Files open, twice so here it is in design, mode and here it is in preview, mode so, that's ctrl shift V. Ctrl. + J. Opens. The pan also ctrl, J opens. The panel where you can see the problems in the output you. Can hit ctrl J again, to close it. Ctrl. I. Selecting. Belonging you do ctrl I again it goes down and select more lines. Ctrl. K and then Z. Zen. Mode, which. Is you know no distractions K. Goes. Out of it alt, shift F. Is, important. That is, format. Code. So. If I go to a code, unit, that has, unformatted. Code. Like. This guy unformatted. Code I can, do alt, shift and. Then F and. That formats. The code for me so this is very useful because you know indentation. Is very, important. For readability of your code. Another. Thing. That is important. Is, multi-select. Like, click. I have. Added. A, quick little, page. Where, I have, the number and a name field in a new customer, list. There's something, that I, want to show you as multi-select. So, if I click over, here and, then, I click I use the Alt key I press down the Alt key and I click down here to, notice. That there are two. Cursors, and now, if I go in here and I. Enter. It'll, do. The same thing, that I'm entering in my keyboard. In multiple. Spots. So if I want to add. An application area. To. The. Page. You. Know this adds it in multiple places so, this is a very useful kind, of shortcut. That's. The multi, cursor. Shift. Alt and click so, if I click here at the start of. Shift. And then I do shift, alt and I. Enter. Here you can see that that is a block so you can sing block. Selection. F2. Were names a symbol so you can go into a symbol and do f2, so let's go into the, code. Unit and we go into a, symbol, then, we do f2, we. Can actually, change. This. Customer. And. That. Changes. My customer, everywhere, so if I do. Ctrl. Z my. Custo, here, and I have my cust, the same. Reference. Here, I do f2, and I change it to my, customer. Just. A little bit different it'll, change it everywhere, that that symbol, is used. That's. Ctrl. F to. Select, all instances ctrl. D select, next instance, so if I do ctrl. F. To, ctrl. F, to, see it, selects, all everything. So my custom, I cust my cost control. D goes, to the next. That's. That, so. Let's go back to the presentation. The. Next. Part. Is about. Debugging. I'd, like to show you one simple trick on the debugger, I'm not going to explain how it works this, is just the tips and tricks video and I have a trick that one might forget for the debugger which is conditional, debugging. So. Let's go back to the. Azure. VM, let's, open the.
Go, For debugging, al, which. Is a. Code. Unit debug, something and, I, am going to set a breakpoint here, on this variable now, I'm going to hit f5, which. Is going to build my solution, and start. Just. To show you this. Is. Subscriber. To code unit 40 on log, after log in, start, so. In business central starts, by, the time we get after the, login we. Should find, a breakpoint, in so this goes into the sylia sign and. We should see a breakpoint notice, by the way that my status. Bar has, now turned orange, from a different color so. Now I'm in the, process of, debugging this, guy. So. As soon as it hits that on after login. No. It hits the breakpoint so, let's take a look at the locals now. My value, is 0 and I play it I, go. And it breaks again and now my value is 1 so. I'm hitting this loop every single time which is cumbersome, so I only like to jump it to. Where, the value is 60, so I right click on the breakpoint, and I, click on edit breakpoint. You, know value. Equals. 60. Hit. Enter that condition has added, so when I play, continue. Or hit f5. See. How it jumps right to where the value it goes 60. So. You can edit the breakpoint, while debugging, you can set this condition. As you're in the code so you know exactly where, it's going to start. Debugging, and, I also like to point out the call stack so it, goes from company, open to company upon login management. To login start, on after, logging start, etc, etc and, so when, you click on all these. Spaces. In the call stack it'll. Show you all the code that was. Executed. As it, ran, through stack. Pretty. Cool let's, go back to the presentation. Next. I'd like to show you a few interesting vs, code extensions, that, I think are interesting to, use in combination with al app development. Before. I do that what, are extensions, exactly. These vs, code extensions, well. They are no js'. Services, each, extension, runs as a separate, host process, which, basically means that they won't interfere with each other they, can't talk to each other either nor, do they interfere, with vs code itself it, just extends. It with new functionality, so. What, functionality. Well. There can be a bunch of stuff that comes with extensions, an extension. Can be as simple as providing, for example, a few snippets like. I've said before you, can add some snippets of your own you. Can provide. Them to Microsoft, and see if they want to include, them in their product, but you can also provide, an extension, pack yourself and include, a whole bunch of snippets that are more, useful than the snippets, that are a part of the al language, extension, itself. Or. It, can be as complicated as providing, a complete language. Including. Its own implementation. Of a debugger a compiler. Syntax. Highlighters, icon, packs so, a wider range of functionality. That can be added on top of your vs code to. Make it act like you want it to act so. Let's. Dive into, a few extensions, which I think are interesting for.
You To use as an al developer, a. Snippet. Creator, is a simple, extension which, helps. You create snippets, so. Let's take a look at this. We. Go into the extensions. Node. In Visual Studio code. Snippet. Cretur. And. This guy let's. Install this see, how quick this is we. Reload, this. Let's. Go into the Explorer. And. We'll go into the. Create. Snippet, al. This. Is an example of a customer, wizard and so, wizard page is something that is not included, in the wizard so we could select. All of this and say, ctrl shift P. Create. Snippet, and, from. There we select, the L language, we. Say well the name is a wizard. The. Snippet, shortcut, is T. Wizard. This. Template description. Lets. Go into the you snippet, al, which is a blank, layout, file then we. Start. By. Typing T, wizard, wizard. User, snippet, select. That creates. That object. As part of the wizard so. This. Is a starting, point right so I can go into ctrl, shift P, I can, go to configure, user snippets, I. Select. The Al Jason, and in there is my snippet, for. The. T. Wizard so, from here I can get, started, it's a it's a spot to get started, so this is quite a complicated. Type. Of wizard, type. Of snippet, and so, in here you could create like your tab stops your variables. Or choices that you can make based on that but, just to load this as a snippet, is a very. Useful. The. Next extension, is the get history, extension. Which, is very useful because you can look at the get history with graphs and details you. Can see the details of a commit with including. Author. Information, you. Can look at previous copies, of the files and compare, them to each other so let's take a look. We. Go into the extensions. And then, we look for a get. We. Are looking for let's. Install this guy. So. Now I have this installed, I can go into my. Explorer. When. We use this extension we go to shift. Control, P we. Take a look at the git log and. In. There we can take a look at the code cleanup for instance for codecop. So. Good at editing. Hacks. Compare. Against the previous version, and we, can see that we've added the parentheses, based, on what the code cop tells us and that was one of those code analyzer. Issues. So, this, is one of those changes that you can look at the git, history, based, on this extension. The. Next extension, we'd like to show is the rest client and, the rest clients can be used to send and cancel, and rerun HTTP. Requests, from. The editor and it. Also shows the response, right into the editor itself so, from. Within visual studio code you send. The requests and it shows the response immediately, within Vizio's. Visual, studio code it, supports, multiple requests. In the same file and it recognizes, the different, calls. And you can do different protocols. At the same time in the same HTTP. File. And I'll show you in a minute and the, authentication. Can be beige basic. Or digest. Or SSL, client certificates. You can, specify variables. In there and generate code in. There as well so it's very useful, for all your web service, stuff. You. Can have nav, web services, and external, web services, at the same time. Let's, take a look at the rest client. In. Visual Studio code, so. The extension, and I'm in the extensions. Page. In here the, rest. Client is the. Rest client for Visual Studio code so. Let's go and take a look at some, of these, files. That we have so, in this folder we have a, number. Of web, services. Number. Of Eyal file so I have a code unit called, my code unit web services, with a procedure, called of the method. Procedure. Called the method with a parameter, and a. Procedure. Called the method with XML, port I. Also. Have a query so the query is called my query web service. And. I also have an XML, port called my web service, XML, port which. Was used in this code, unit and. Then I also have defined, these web services so my code unit web service is defined as a web service within, the tenant I also, have the query specified. As a web service within, the tenant and, so in addition to that I have a number of HTTP. Files, so. One, to just show you that it works is. A call to an azure website. Wabo. Provided, this where, he has a, parameter. With, name one, Waldo. When. I take. This guy out. The, send, request button, so is is. Automatically. Removed, so if I go. Back and get this get request, back in there it recognizes. That as a send, request and so the HTTP. File within, the contest, of this rest client, recognizes. These, calls so if I send this request out this, is a request. Sent to an. Azure function, that via KHOU put together as a demo, for directions, and. Other conferences. It still, works so hello, Waldo, let's. Take a different. Value. Hello. Folks. Having. A good, time. If. I send that request in there it says how long ready to go folks are you having a good time, so that, part is working so we can verify that this is actually, working.
Rest Client, let's not save this. Then. We have the call. To the, nav. Calls, so, I have, a soap. Request. And. The soap is the, workflow. Items, this is just a regular page and so this is a, format. As a soap, request and if I send. This the. Response. Should, be an XML. Response. As. This, is shown, so that's a soap request. I can also send this as a no data request, in. The. Response. Should be coming. In pretty quick. Right. This is also an XML, request, and, if I send in the. OData. Before, a request that should come back with a JSON. Response. So. It's the same response. It's just formatted, and Jason instead, of, XML. So. If I go into my web services, setup, this. Is essentially, a way to test. These things right so I have my XML, ports I have, my query I have my code units and I want to just make sure that all these things are, working, and so by, using the rest client in here. I can, figure, out that you. Know I can do, a web request with, my query web service, as an OData v4, request. And the, content, mobi this. JSON request and, so this is a very powerful. Way, of testing your web services, and this. Is one probably, one of the most useful ways to, figure out whether your web. Services, are actually working. The. Next vs code extension. Is for, Microsoft, sequel server and. There. Are a few important, feature of this extension, one. Is the, feature of, creating connection profiles, you. Can go directly to a sequel server you can go to an azure sequel, database, in our, case we can go into the sequel server that's inside, of the nav container, the docker container, as you. Would expect from the code editor you. Can create, T sequel scripts inside vs, code and. It has all the intellisense. Capabilities. Go to definition, you can create snippets, syntax. Collar a shin as part of it and all, your T sequel is validated. Just. Like you would expect and, then, the other feature. Is that you can actually save, the data and, export it as a CSV or, in JSON, or in Excel so, let's go take a look what that looks like. Inside. Of my extensions. The. Extension. Is actually called ms SQL and, that. Is the Microsoft, developed. Extension. For, the. Visual, studio code. Just. To give, you a quick, look, at what we have here, so we have an editing hacks table, which, is called completely. Useless table, we. Also have a. Table. Extension. Which is an extension upon, the customer, table called just some table extension, and then, we have another table. Called just, some table so, let's take a look at the sequel, that we have, first. To connect, you would have to create a connection, profile. So. Ctrl. Shift P, and. You do mssql connect, I already, have a profile. Created, but you, can create a connection, profile here it's, going to ask for. Connection. Information like the database. Server and the database name, a quick. Way to figure, out what that is is, by opening your Seaside, client, in. Your. Nav container. And. Inside. There, once you connect you, can go into file, database. Information. Just, like you would expect and, then, over here you have your database server. Basename and. Then the, user, inside. Your nav container, is si and it, will have the same password as. Your. Nav. Database, so. That's. The connection information, so. I have just, some. Basic. Information my. Sequel. Statement, of here, is basically. Looking, at table. Names from the information, schema not table where table type equals base table, and table name has this. Number. Over here and that number is, the. App ID, from. Our app Jason. So when we go into the sequel, just, put your cursor in here shift, control P and, then. You say execute, current, statement they'll. Ask for your profile, if the connections, not alive anymore and then, it will go into the, database. To, retrieve some, information. The. Information that, we're getting is that. We have the, Coronis USA database with a completely. Completely. Useless table. With. Just, some other table, and we also have this one that, says customer, dollar and then that number and notice, that all of those tables have that number that app ID is part of the table name and that's, how business. Central, knows how to create. Those linked list tables together, so let's, going to the second statement which essentially. Reads. The, data from, that, customer dollar, app. Table, so this is the companion' table, that, is based on the, table. Extension, right so this has just some. Field add it to the customer, table so, if we go into the sequel statement, and, we. Execute. The current statement. You. Will see that that table, has the number that's the customer, number and the. Additional. Field that's called just some field. And so just like that we also have a just some table if, I execute. Current, statement in that one, you.
Will See, that, there is a number, and, description, and so that, will be the same as the. Just. Some table right, so the number in the description, those. Are the fields so. This is a small. Example. Of how you can use sequel server in. Vs. Code directly, let's. Go back to the. Presentation. The. Next extension, is the PowerShell extension, this. Extension, provides rich powershell, language, support, for vias code so. You can actually use vs code to write scripts into debug, scripts, has, lots of cool features for powershell. Itself such as syntax. Highlighting. Snippets, intellisense. There's. An analyzer, and all the features. That you would expect out of PowerShell. Are also available, in vs code. Lets. Could just go and take a look at our, as. Our VM, so. One, thing that, we like to do is we like to keep the, PowerShell, scripts, in a separate folder so. In. There we have a. Bunch of PowerShell, scripts, and some, of these, scripts. Are reusable. And so we reuse these things I just. Wanted to point out some. Structure. Elements. That we use for these scripts so, usually, we have a, single. Settings, PowerShell, scripts, in which we load the, variables, so, here you see an app dot jason, or an app jason, which. Is a, way to read, the, jason, the app dot jason, into, a variable, and that variable, can. Then be used in other scripts, so, here. You see app dot jason, app. Jason. Dollar, app jason, dot name so, the name attribute of, that object is read into. The app name and so those, are very handy, things to have in such. A settings, file and so what. You need to do is just put all your variables in the settings. Script. And then, you can use them in all subsequent. Scripts. That, you use. I had. Some trouble getting these scripts actually. Work. And the reason is because my. Environment, has. Some, different variables, and some different values that. Are different. From the. Person who wrote these scripts and so if you look in the settings there are some IP. Addresses. And that's all in. Into, these scripts. That I could not make work but let me just walk you through some. Of these, important. Things so what, is very useful, to have is a nav container, to, do the development on and then, also have, a nav container, on the same development. Environment, that you call test server so, the, dev server is, where you would do your development and out, of es code you just hit f5 and that publishes, it right to the service tier and then obviously we, also have a test server where. You can test. Whether. Your install, code units your upgrade code units that sort of stuff all works and, also, it's a way to you. Know check, to see if your install, script. And your upgrade, script, works. As well and so you would have to do is, set. The right dev server and test server, values. And those, would then be used in the other, scripts. So, let me just walk you through some of these, to. Install, an app you, have an uninstall, nav container app this, is an app container helper, script, command, let you. Unpublish, it at the same time these. Two steps are obviously not really necessary. If you have a completely, blank nav container, then, you have a publish, and a. Sync script. And then an install, script, to. Actually, install, it into the tenant. The. Upgrade, script, has an uninstall. And an unpublished. Step then. We have a published, step, with, the last app file so that's the last so, if you have one, point zero, point two, point, zero and then you have a one point zero point three, point zero that's, an upgrade you, go up in version, and so in that case you have to do uninstall. Unpublished, and then publish the latest version, you sync that to, propagate. The schema. Changes, into, the database, and then you start, the nav container, app data upgrade, which, starts, the upgrade, code unit and so, these, scripts. Make. It all very easy. To, implement, any. Changes that you might have and the cool thing about having, all these things, in the same workspace. Is, that, it's kind of embedded, so I have a PowerShell. Folder. With all these PowerShell, scripts, I have, a rest folder, with a bunch of these HTTP. And XML, files I have a, sequel folder with a sequel, script I have these MD.
Lease Markdown, files, and. Still despite, the fact that we have all these different types of files inside. My workspace this. Is still a compile. And, implementable. Package. For, a business, central app and so, it is a really, powerful tool. Visual Studio code is a really powerful tool, to have a complete, workspace, that contains, all these files that you are. Working. With and so you can track, everything in source control you. Can make it part of your same workspace, you can even have user specific. Files in there as well and have, everything embedded. So, those. Are some, really powerful things that. I wanted to mention and. So. Up until now we've looked, at these, extensions. That are all non. Al, specific, so let's go and take a look at some al, specific. Extensions. And, so let's. Talk about some extensions, that were specifically, created for enhancing. The al, language. And so, one. Of them is the AL code outline, extension. The features are it displays, code outline, of the active file in the Explorer, pane it, displays, a symbol, tree not only for Al but also for XML and other types of files the user. Can navigate to the symbols shown, with. A context, menu with some more functionalities. Before, specific, objects, like it run in webclient, and it, shows the symbols from a reference package, which is the. Simple file so let's take a look at it, back. In Visual Studio code, we, have installed. The AL code outline. Extension. Which. If, we look at the home page for, it. As. A number of really cool features, one. Of the things that we have here is that we can right click on an app file and then, we can say open an Al object, browser so, if I go back to my extension. And, going to Explorer, view and, I scroll down to, my app file, I can right click on, that and then say open an object. Browser and this. Shows me a list of all the objects, that are part of this extension, based, on the information, in there like for instance in the tables, I can, click on one of those tables and then right-click and then I can, select, a new card page just. Some table. Card and this. Creates a new, this. Is insane. These are really useful, things this will really make your. Development. A lot more efficient, if you look at for, instance the. Editing. Hacks method, code unit there's. Something, called an al outline, on the left hand side and the Explorer, and, you can click on it and then on the right hand side you can see that when. I click on editing, hacks that. Editing, acts is then also, selected. In that al, window, itself, so, there's, lots of features in here that'll be, very useful, to you as an al developer. That, you can use to, extend, the function, of the. Layout. Language. So. This. Is the main page on the marketplace, you can also go into github, and, so. The. The creator of this. Extension. Has opened, up his. Coat. So it's all open source you. Can create new issues. You can do pull requests, and so, you can actually be part of making, something, like this better so, it's it's open source you can go in there you can see how it all works and. You can make modifications and. Improvements the. Way that you see fit. The. Final extension that I'm going to show you is, our own CRS. Al language, extension, which.
Was Written by Waldo, and, he. Has a, bunch of things. In there one, of the things that he started out with was a bunch of powershell. Modules, that, he's now included. In this al language extension, for vs code I was. Told that he is these. Days he's doing all of his PowerShell, work in BS code so he's not using the PowerShell, ISE, anymore, then. Another, important. Feature, is to run an object, in. The various different clients, the, Windows client doesn't work from. The nav container. Yet. But. You. Can run, an object, a page straight. From vs code in, any client, that you select. So if you're working on a list page you can actually run that list page from vs code by, using one of these CRS, commands, and, then another part. That is really useful. Is an, organization. Functionality. In this organization. Functionality. Allows you to rename a single, file but. It also allows, you to reorganize. Your entire, workspace, and I'll, show you what that looks like in, just a minute and then. Of course we also have a bunch of snippets. Let's. Go into, the azure VM. So. In my, vs code I am, in my extensions, list and here's. The CRS al language extension, and just, like the al code, outline, you can click on this that takes you to the marketplace, from. The marketplace you can also go to our. Github. And this. Is an open source so you can see exactly what's, happening, and how it all works and. You. Can you know make a clone out of it you can do a pull request, although. Is eagerly. Waiting for issues, to come in, ideas, on how to make this better, and, you, know we. Look forward to hearing. What you think about it and how we can make, it better. So. Let's. Close. This I must. Go back to our Explorer. And. So you, know I can, for. Instance go, here. Go. To just some page this is page. 50,100. So, I can do ctrl, shift P. Object. Client. Enter. And that, thing opens, it in. The. Web client. Just. Some page very. Useful feature, because without, that you would have to go into launch Jason, and set the startup ID from. There and that's always a, lot, of extra work now. If. You look at all these files, this is not. Very. Useful the, way that they are all called, so this is called a three editing, hack method. Dot al, the. File is code unit 50,000, 101. So if I go to. CRS. And. Rename, the current file. It. Actually. Creates, a file. Called Co d5o. 101. Dot editing, hex math, dot al, so the, type. Of objects. Plus the ID plus, the name is all, part of the. Renamed. File. You, can also go in there and. Rename. All. Files, you. Can also do, reorganize. Current, file and. What that does is it creates. A folder for Al a folder, for code in it and it moves the code unit in there and, then another option. For this is that. There is an option to reorganize. All files or rename all files and that completely, reorganizes, your. Workspace' I seem, to be having some sort of issue in my workspace so it's not working correctly, I'll. Make sure that I add a issue, an, issue, on our github and report, this to Waldo so, that he can take a look at it but, when it works it's really a useful. Piece. Of functionality because, you have a completely, reorganized. Workspace, where all your al. Objects. Are organized. By object, type with, proper, names and it's really useful because then you can see if you have some, gaps. In your number range and all that sort of things so in. Combination. With, some other. Extensions. That look at your code and the code analyzer. The, tools are, maturing. At a really, fast rate and it's. Really cool.
To See how fast. It's going because we've, only been using Visual, Studio code, for about a year now and, it's. Really nice, to see that the. Capabilities. Are just growing. Exponentially. It's really really, cool to see. Let's. Go back to the presentation. That. Was it for this video in, which we've looked at some best practices, on how to, use vs, code and, some extensions, that can make your life a lot easier if you. Want to learn more about business central, Apps please visit, the, website. On your screen and. All, that's left for me to say is thank you so much for listening to me for, taking, some time out of your day to learn about these things, and. Have a great day.