Author Archives: Kepty

Kepty4Beginners: How to create a basic entity

In today’s beginner series article, we will look at how to create a basic entity such as Item, Customer, Vendor etc.

Creating basic entities is one of the core things anyone has to know. It is also necessary to know which properties must be defined (LookupPageID, CardPageID), which type of PageTypes should be used etc. After this video, you will be able to create the fundamental entities in your projects correctly and without any hesitations.

OnAfterLookup: New page field trigger coming in v18

One of the news in AL Language that is coming with the upcoming major version (Business Central 2021 W1) in April is a new trigger AnAfterLookup. The new trigger is described on Microsoft Docs (however, the description is still a bit confusing…).

As the Lookups are often used, I already tried what’s new and how we can improve our projects with these changes. Unfortunately, there is no documentation available at the time of this article, so I am unsure what is intended and what is currently just a bug (as this is still only a part of the preview version).

Although I could use the triggers in some small examples, I still can not find any scenario where the OnAfterLookup trigger can be useful in the real world. Let’s look at some examples.

OnLookup & OnAfterLookup

The OnLookup trigger is known from the beginning of C/AL Language. It is used to build more complex Lookups that can not be created using TableRelation (or any similar property). It replaces standard lookup features (runs in a place of regular lookup feature).

Until the Roletailer Client (NAV2009RT or rather NAV 2013), there was no visual/functional difference between lookups created through any property or OnLookup trigger. However, with Roletailored client (and Web Client), there is a vast difference – a dropdown list available only for relations made through TableRelation property. The dropdown list is beneficial for users, and developers must have it in mind when creating relations.


OnAfterLookup trigger does not override the standard trigger from the TableRelation. It is triggered once the record is selected from the Dropdown box; however, if the user decides to use a standard lookup list using “Select from a full list”, the trigger is not fired.

With this in mind, it is unsurprising that both triggers written for the same field are useless (OnAfterLookup is not used as OnLookup does not use dropdowns). In the first example below, the OnAfterLookup trigger is never called.

 field("TKA Tariff No."; Rec."TKA Tariff No.")
     trigger OnLookup(var Text: Text): Boolean
         Message('Old Value: ' + Text);
         Text := YourOwnLookupReturningSelectedRecord()
         Message('New Value: ' + Text);

     trigger OnAfterLookup(Selected: RecordRef)
         Message('Selected Value: ' + Format(Selected));

If we only use the OnAfterLookup trigger, the trigger is fired once the user chooses the DropDown list value. As a developer, you get a RecordRef variable that contains the selected record.

The second example shows how you can print information about the selected record. However, I am still unsure how to use it in the real world – we can just get information from the selected record (and even only for those made through DropDown List, not the full list).

 field("TKA Tariff No."; Rec."TKA Tariff No.")
     trigger OnAfterLookup(Selected: RecordRef)
         TariffNumber: Record "Tariff Number";
         Message('Selected value: ' + TariffNumber."No.");

Do you have any ideas on how to use this functionality within real projects? Have you ever used the Text parameter in the OnLookup trigger? Please share your thoughts in the comment section.

Kepty4Beginners: How to create an AL Project

The first article from my new youtube channel is here (if you want to find out why I have decided to start my own youtube channel, see here)! This is the very first video for beginners – how to create a new AL project.

In this video, we will look at how to create a new AL project in Visual Studio Code, the core setting files in every project (app.json, launch.json) and what needs to be set up able to publish an extension to your own Business Central instance.

How to install Business Central (developer) preview version

In the last weeks, I got some questions about installing the developer’s preview version (the Insider build) of the Business Central. This version is available through Artifacts for docker similarly to standard versions; however, they are available only for Microsoft’ partners.

If you are a partner, you can find your access code directly in the Microsoft Partner Center (Collaborate -> Overview -> Packages -> Working with Business Central Insider Builds). On this page, you can download the .txt file that contains sasToken (token you need to download any of insiders builds).

Creating the container is similar to creating the standard container; the only difference is the “sasToken” parameter in the Get-BCArtifactUrl command. See the whole command below.

 Measure-Command {
   $artifactUrl = Get-BCArtifactUrl -country base -select nextmajor -sasToken $sasToken
   $credential = New-Object pscredential 'UserName', (ConvertTo-SecureString -String 'Password' -AsPlainText -Force)
     -containerName Your-Container-Name          
     -artifactUrl $artifactUrl
     -Credential $credential          
     -auth UserPassword
     -imagename Your-Own-Image-Name
     -includeTestToolkit `
     -licenseFile 'C:\PartnersLicense.flf'

Visual Studio Code AL Language extension from Insider’s build

With the new major version, there are always many changes to development. To use these changes and try to create new objects, new structures, or check changes to standard procedures, you have to use the new version of the AL Language extension for Visual Studio Code.

The new version is not available directly through Visual Studio Code until the full version of the Business Central is officially published. However, the extension is available directly on the image you downloaded when the container was created (it could be a little different path in your case):

C:\bcartifacts.cache\sandbox\18.0.22317.0\platform\ModernDev\program files\Microsoft Dynamics NAV\180\AL Development Environment

This .VSIX package can be installed manually in Visual Studio Code (Extensions -> … -> Install from VSIX…).