Wednesday, 21 December 2016

Developing Extensions Using the New Visual Studio Code – Part 1

I would like to start developing a simple extension using new visual studio code and lets start together.

I would like to have functionality which allows to add a Reason for Lost Quote on Job Card.

Let’s start with step 1 to achieve above functionality by creating an extension using Visual studio code.

We need to explore about the Visual Studio Code and AL language Extension.

All functionality in Dynamics NAV are coded in objects. Table objects define the table schema that holds data, page objects represent the pages seen in the user interface and codeunits contain code for logical calculations and for the application behavior. These objects are stored as code, known as AL code, and are saved in files with the .al file extension.

Note: A single .al file may contain multiple objects.

There are two other special objects which are specifically used for building extensions. Table extension objects and page extension objects are used for defining additive or overriding changes to table or page objects.

·        The table extension object allows us to add additional fields or to change some properties on a table provided by the Dynamics NAV service. In this way, we can add data to the same table and treat it as a single table.

Along with defining other fields, the table extension is where we write trigger code for our additional fields.

·        The page extension object extends a Dynamics NAV page object and adds or overrides the functionality.

The structure of a page is hierarchical and breaks down in to three sections. The first block contains metadata for the overall page; the type of the page and the source table it is showing data from. The next section; the layout, describes the visual parts on the page. The final section details the actions that are published on the page.

If we want to modify existing fields and groups on a page, we use the modify() function
When we want to start creating our own project, we need to create a new project to contain it. Visual Studio Code manages projects by including all files from a directory. Whatever files exist in that directory are then part of our project. In addition there are two other configuration files; app.json and launch.json. We can define these ourselves, possibly by copying the files from sample code or we can have the system autogenerate them for us. Building the solution (Ctrl+Shift+B) will create the app.json file and publishing (F5) will generate the launch.json file.

So let’s create a folder for our Project.

Open Visual Studio Code
Click on Explorer

Click on Open Folder
Select the folder which we created above.

We need create a table (Reason Code for Lost Quote) to Specify reason codes. Reason codes are used to indicate why Job Quote was Lost.

Click on New File as shown in picture to Create .al file

Name the file as

If you go back and check above folder then we can see the created .al file

Now create 2 fields in table

Typing the shortcut ttable will create the basic layout for a table object when using the AL Extension in Visual Studio Code.

Now it looks like

Edit table id

If you try to add any 50000 series then it shows error as shown below

Let’s create table with id 70000000 and Name "Reason Code for Lost Quote"

Edit the Myfield to “Code”

And Datatype of field from Integer to Code[20].

Add field 2 as Description with Text 50.

Now the object looks like this.

This is how to create new table using new Visual Studio Code.

We will see how to add new field in existing Job table in next blog.

Stay tuned.


  1. Hi, what's the name of the AL Language extension in VSCode?

  2. This comment has been removed by the author.

  3. Also not seeing the intellisense shortcut on "ttable" - is there any other prep work that may be needed? I have VS code running and have the "Dynamics NAV C/AL" language extension installed. Is that not the correct one?