Monday, June 18, 2018

MSDYN365BC - Introduction to VS Code Editor.

Hi all,

In the last article, we have downloaded and setup Business Central Image using dockers & Powershell.

If you are new to this series you can read old articles in this series using this Table of content Page.

In this article, we will discuss New Code Editor which will be required as we go forward to coding using that.

Open Visual Studio Code.




A Welcome screen will popup as shown below. As we can see there are are some activities in the center area. I would recommend seeing whats in all these areas to be familiar with the new code editor.


Remember VS Code Editor is not only for AL Code or Business Central Code. Its a common & one of the most famous code editor which can be used to code with multiple languages. It's completely configurable the way you want it, Look and feel, the programming language of your choice and completely extendable as a developer.
 
Let's discuss about the panel on Left one by one.

The First option is an explorer as you can see in the screen below. This is where all your files for the customization that you do will reside. Each customization (old NAV Terminology) resides inside a folder. At any given point of time, you can have one active folder open that means you are developing or modifying one customization.


Next Option on the Left-hand panel is Search, that will allow you to search in the open folder. If you have a huge extension/customization with multiple files involved this tab allows you to search files within the open folder.


The third option is the Source Control. So if you want to use source control like GitHub in future this tab will be used to check in the changes to GitHub or any other source control that you use.
** Github have a build in the interface with VS Code Editor. I will be using GitHub as source control during this blog series.


The fourth option is the left-hand panel is mostly used by every developer. Yes, you guessed it correctly its the debugger. We can debug within Visual studio code for the customization that we have written for Business central. and the environment will be similar to what we are used to. The debugger will also debug with the base name code that is written behind the scene.


The Fifth and the last option in the Left-hand panel is extensions.
When I say extensions please don't get confuse with NAV Extensions.
These are VS Code Extensions that allow you to Extend the behavior of  VS Code Editor. If you remember on top I specified that VS code is not for AL Programming, but Microsoft has created a VS Code Editor Extension to use AL Programming using VS Code Editor. There are so many extensions available for VS Code Editor and you can build extension if you want. There are so many that are available for AL Programming and we will be using some of them later in this series.


Lets now visit the status bar at the bottom of the VS Code Editor screen and see what options are available there.

Gear Options provide you so many options like - Downloading updates, Changing the themes, color themes, creating snippets, Shortcuts, and settings.


At the bottom ribbon, you can see Errors and warnings count in the left-hand corner and on the right-hand corner you can submit a feedback or bug via twitter and notifications icon that will pop up as you have some notification to your workspace.

Let's see some actions in the Gear which we will be using going forward. First, one that I would like everyone to visit is Keyboard Shortcuts.

All the keyboard shortcuts are available here. If you would love to use a mouse that's ok, that's like to use the keyboard all the time during my coding. We dont need to remember this big list but at least know where it is.


User Settings is something that we will like to set up that based on your requirements. Like our old development environment these are not Yes and No Options that you can set with a limited scope. VS Code Editor User settings are configurable files that you can decide for yourself and will not impact anyone else as you can see below.

In the Left-hand panel, you can see all Default user setting and you can add what you want for yourself in the Right-hand panel. We will set some user settings as we go forward, you should remember where they are later in the process of learning AL Code.


Let's go back to our workspace and I will open a folder just to show you other options that are available in the workspace itself.



As you can see above there are 4 options in the workspace.

1. Problems - Will specify what is the issue in the code.
2. Output - will show us the progress while deploying an extension, downloading symbol or any other task that we will do.
3. Debug Console - Will show us the debugging process.
4. Terminal - In the terminal, we can use it as DOS Prompt or Powershell prompt with respect to NAV. The Terminal let you switch between available options based on what all terminal extension are part of your solutions.

I know that is a lot of theory and no action. So let's do an action.

As I told earlier that VS Code Editor does not know what I want to code against and I need to help VS code Editor is specifying that by deploying an extension. Let's navigate to the Fifth option in the Left-hand bar and Install AL Extension from Marketplace.

Search For AL Language and install the extension as shown below. After installation of this our VS Code Editor will understand the AL Language.


That's all for today and in next article, we will learn more about AL Code, How to connect AL Environment to the Database, How to download symbols and how to publish our first demo extension.

Stay tuned for More.

Regards,
Saurav Dhyani
https://saurav-nav.blogspot.com