21 February 2019

Add a logo to a Microsoft Dynamics 365 Business Central Extension

I saw a couple of forum questions about how to add a logo to an AL Extension and I thought to share a quick guide on how to. 

If you publish your new extension to Microsoft Dynamics 365 Business Central and then navigate to Extension management page, you will see your new extension as below (My extension is "Demo Extension"). 

You only need to follow a couple of simple steps to add a logo to your new extension.
1. Place the image into your Repo.
2. Refer to the image from app.json file

You can simply copy the image to any folder that you have within your workplace. I always prefer to keep things organize so I know where my .al files and other extension related files are. Therefore I will copy the logo to my res (resource) folder where I keep all my resources related to the current extension. 
Once the above step is complete, you can open the app.json file and set the logo setting to refer to the logo you just copied. Please refer below screenshot :

You might have noticed that my file path starting with ".", it means the current working folder or in my case the Repo.
Once you have the "logo" setting set in the app.json file you can simply compile and deploy the extension to Microsoft Dynamics 365 Business Central. This time it will get published with the logo.  

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

19 February 2019

Runtime Packages for Business Central On-Premises

Before you go through this blob, I suggest you read my blog post "Your program license does not allow you to publish" to get an understanding about the Runtime Packages. 

Runtime packages are designed to help the distribution of extensions. You can generate Runtime packages that do not contain AL code. Runtime packages allow protecting the AL source code. 

The biggest advantage to me is that extension in a runtime package can be installed on a server that does not have a developer license. In other words, you can install the runtime extension to the production without changing the customer license to a developer license. 

The license is only checked on the server where the runtime package is generated. 

How to get the runtime packages:
It is a must to install the extension into an on-premise instance to export the runtime package. next step is to connect to the instance through PowerShell and then download the runtime package. 

You can use "Get-NavAppRuntimePackage" PowerShell cmdlets do download the extension:

 Get-NAVAppRuntimePackage -ServerInstance DynamicsNAV -AppName 'Proseware SmartApp' -Version -ExtensionPath 'Prosware SmartApp_2.3.4.500_runtime.app'   
Once you have the runtime extension you can use the Publish-NavApp and the Install-NAVApp PowerShell cmdlets to publish and install the extension. 

Runtime package only works for on-premise installations and cannot be used with AppSource. Addition to that  debugging experience is very limited since the no source code is available 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

Your program license does not allow you to publish

We recently ran into a new issue when we try to push one of our extensions to Microsoft Dynamics NAV 2018 On-premise installations. 

We used PowerShell script to upload the extensions to production and we did this couple of days ago too without an issue. However this time we got the below error during the installation :

"Your program license does not allow you to publish <table extension name>"

The instance was running with the customer's license and we realized we need to find an alternative method. We had a couple of options, 
1. Change the license, upload the extension and then change the license back
2. Create a new instance and use a development license to upload the extension
3. Try the runtime app option

We first went with the option 01 but we end up with the same error. Even though we upload the license to the instance we could not restart the service, therefore, we were unable to bypass the license issue. 

We went with the third option this time to see how it's going to work. If you like to read more about it please use this link.

We install the extension to the Development environment which was running with the Developer license and then used below PowerShell command to export the Runtime Package. 

 Get-NAVAppRuntimePackage -ServerInstance DynamicsNAV -AppName 'Proseware SmartApp' -Version -ExtensionPath 'Prosware SmartApp_2.3.4.500_runtime.app'  

Once we got the Runtime package we install it to the production environment with the use of the Publish-NavApp and the Install-NAVApp PowerShell cmdlets. 

Runtime package installations skip the license check so you can use this option to install extensions to a Production environment without changing the license. 

** Thank you Isa Sen for helping me to prepare this blog post.

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

Function Overloading in AL with Option and Integer

We never had the luxury of overloading a function in C/AL, but with the AL we have that ability. Which means you can use the same function name with different parameters. 

This blog post is about a small glitch in the function overloading in AL and I will write a separate blog post about function overloading and its implementations (Excited about it). 

I had below function signatures in my code and each of these functions is called from 6 different places. 
 procedure InsertData(Code: code[10]; lDelimiter: Option Comma,Tab,SemiColon,"Fixed")  

 procedure InsertData(Code: code[10]; configType: Integer; Config: Boolean)  

However, I noticed that the second function got 12 references from the function calls and the first one got none (should be 6 each).  

Reason for the 
glitch: Option is also passed as an integer to the function so compiler sees both the function signatures as same. 

What I assume is, even though the AL compiler does not give an error during compiling of the code it still sees both the function signatures as the same. That is why it is referencing all the function calls to one function.

** In order to replicate this, function signature needs to have the same number of parameters.

** Thank you Stephen Gichure for helping me to prepare this blog post.

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

Git Bash on Visual Studio Code integrated terminal

Visual Studio Code (VSCode) uses PowerShell by default in the integrated terminal. How easy would it be if Bash can be integrated into VS Code terminal?

This is how my VS Code terminal looks like now:

This can be achieved with a few steps.
1. Download Git (https://git-scm.com/downloads) and during the installation click below steps.
2. Select "Use Visual Studio Code as Git's default editor" :

3. Select "Git from the command line and also from 3rd-party software"

Let the installation finish.
4. Then restart the Visual Studio Code.
5. Open Visual Studio Code and press and hold Ctrl + ` to open the terminal.

6. Open the command palette using Ctrl + Shift + P.
7. Type - Select Default Shell

8. Select Git Bash from the options
9. Click on the + icon in the terminal window

The new terminal will be a Git Bash terminal.


Please provide your feedback with a comment.
Thank you and Regards,
Tharanga Chandrasekara
Read more »

06 February 2019

The runtime version of the extension package is currently set to '2.1'

While deploying one of our base extensions to a customer tenant we got an error with "Unable to Install the Extension *******". This was the same extension we deployed to the same tenant couple of days ago with a different version. We revert our changes and try to publish it again but the same error. 

The error was not much descriptive so we could not identify what was the issue. Therefore we deploy the same extension to one of our on-premise servers and check the event log. 

We got the below error from the event log:

The runtime version of the extension package is currently set to '2.1'. The runtime version must be set to '2.0' or earlier in the app.json file in order to install the extension package on this server.

Our app.json file of the AL extension didn't have the "runtime" property defined so I assume when we uploading the extension to Business Central, upload function took 2.1 version as the default which was the latest at that time. However, the tenant was not supporting the 2.1 version. 

We add the "runtime": "2.0" property to app.json and then we upload it to Business Central. This time it got uploaded to Business Central without an issue. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

Control Source code download from an AL Extension

Microsoft Dynamics 365 Business Central extensions now allow partners to decide if they want to share the extension source code with others or they want to go put it into a little black box.

If the extension contains code related to specific customer requirements then I think it is up to the customer and to partner to discuss and decide if they want to keep it open or close. If both the parties want to put the source code into a little black box then it is advisable to add the customer to the repository or share the code with the customer. Reason for that is, if the customer decided to change the partner then the next partner should be able to change or alter the existing changes to support the customer's new requirements. 

How to control source code download:
This option of "showMyCode' available on the app.json of the extension. 

If this is set to false that means others will not be able to download the source code. 
showMyCode : false

showMyCode : true

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

Get all Docker images available for Business Central

You can use below PowerShell script to get all the Docker images available for Business Central. This is very useful if you always work with Docker Containers and want to test your changes with different localizations and different builds. 

If you are still new to docker then its better to read my previous blog post about the Docker and containers before jumping into the script. 
 $ResultingObject = @()  
 $result = Invoke-WebRequest -Uri "https://registry.hub.docker.com/v2/repositories/microsoft/bcsandbox/tags/?page_size=250"   
 $JsonObject = ConvertFrom-Json -InputObject $result.Content  
 $ResultingObject = $JsonObject.results  
 $ParentId = 1  
 while ($JsonObject.next) {  
   $result = Invoke-WebRequest -Uri $JsonObject.next   
   $JsonObject = ConvertFrom-Json -InputObject $result.Content  
   $ResultingObject += $JsonObject.results    
   $percCompleted = [Math]::Round($ResultingObject.Count / $JsonObject.count, 4) * 100  
   Write-Progress -Activity "Processing tags" -PercentComplete $percCompleted -ParentId $ParentId   
 #Display all tags:  

If you want to filter the result you can use below code. In this example, it will filter the Docker images which belong to the W1 version. 
  #All W1 tags:   
  $ResultingObject | where name -like ‘*-w1*’ | select name   

Thank you Waldo for the script. Please refer original blog post if you need more information. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

Quick Fix : This AL extension version for Visual Studio Code cannot be used with the specified server.

If you recently pulled the latest Business Central image or update the visual studio code you might have already faced this error. 
This AL extension version for Visual Studio Code cannot be used with the specified server.
Please update the AL extension from the Visual Studio Code marketplace.
Additional information:Server details
- Runtime: 2.3
- Web API: 2.0
- Debugger: 2.0

AL extension details- Supported runtimes: 1.0, 2.0, 2.1, 2.2
- Supported Web API: 1.0, 2.0
- Supported debuggers: 1.0, 2.0
Reason for the error: 
AL extension (2.1.69331) that you download from the visual studio market place does contain the latest updates which work with the latest releases of Business Central and Visual Studio. 

How to resolve it:
Till the visual studio market place extension get its latest update you can install the AL Language extension from the Business Central CU 3 product DVD. If you are new to this you might want to read my previous blog post about how to install an extension to Visual Studio. 

Go to Visual Studio Cod and navigate to Extensions. Then select install from VSIX.

Select the Visual Studio Code AL Extension from the Business Central Product DVD. 

Install the extension (2.1.79379) and reload the window. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

04 November 2018

Getting Started with Dynamics 365 Business Central APIs

API (Application Programming Interface) is an interface which allows applications to talk with each other. Simply put, it is more like a website, where you make a call to the server and you get a response from the server. 

Dynamics 365 Business Central (D365BC) expose many "ready-to-use" APIs which allows seamless integration experience between other service offerings and Dynamics 365 Business Central. Spring 2018 release introduced this new capability to Dynamics 365 Business Central (D365BC) and from every month "ready-to-use" API count is growing. 

Apart from "Ready-to-use" APIs, a user can build their own custom APIs and that will discuss in a separate blog post. 

This blog post will go through basic API requests and will show how to use Postman to test these. 

I have created a collection called "Business Central - API" and in that, I have defined 2 variables so I do not have to type the Base URL over and over and also to store the tenant ID.

Base URL:

 https://api.businesscentral.dynamics.com/v1.0/<your tenant domain>/api/beta  

You need to replace <your tenant domain> with your Business Central ID. 

In the "Authorization" tab set the type to "Basic Auth" and enter Username and Password to login into Dynamics 365 Business Central (D365BC). In here I used Web Service Access Key to login to Dynamics 365 Business Central (D365BC). 

Get Records
Once the Base URL and authentication is set you can create a GET method for {{BaseURL}} which brings all the available APIs as below:

How to retrieve a list of companies available


Return JSON will have all the available companies and their unique IDs

If I want to work with one specific company, then you can store the company ID in an environment variable in Postman. This will make life easy if you going to use this ID in multiple requests. 

I have used a small JavaScript to store the company ID based on the response body. You can achieve this by simply navigating to Test tab and pasting the below script. What this script does it, it cast "responseBody" to a JSON data and then read the company id and the value to "Env_companyID" variable. 

 var JsonData = JSON.parse(responseBody);  
 postman.setEnvironmentVariable("Env_companyID", JsonData.value[0].id);  

Once the script is complete simply execute the {{BaseURL}}/companies. This will return the list of companies and our small JavaScript will store the first company ID in "Env_companyID" variable. 

Now with the stored "Enc_companyID", you can filter the return JSON. 


From that forward your any request will work on that filtered company. 

Get all the General Ledger Accounts


Get all the customers and store first customer ID in Environment Variables


Set below script it test tab:
 var JsonData = JSON.parse(responseBody);  

Filter Records

In this we are filtering customers based on Customer ID we stored in environment variables. 

Update Records

We need "@odata.etag" to update records in Dynamics 365 Business Central (D365BC). Use below JavaScript to store etag in Environment Variables. 

 var JsonData = JSON.parse(responseBody);  
 postman.setEnvironmentVariable("etag", JsonData["@odata.etag"]);  

Once the script is ready to send the request and get the response back. That will set the etag in the Environment Variables. 

After the etag is set we need to change our method to "PATCH" and in the header tab set the "Content-Type" to "application/json" and add another key 'If-Match" and set the value to {{etag}}

In the body of "PATCH" request add below JSON. This means to change the display name to "Tailspin Toys - Update"
    "displayName": "Tailspin Toys - Update"  

Execute the command and return JSON will have updated "Display Name"

There are many new possibilities opens up with new APIs and will post more about new APIs and custom APIs. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

11 August 2018

What is Docker? What are Containers?

Every year Microsoft is releasing a major version of Microsoft Dynamics NAV and on top of that, they release monthly updates for each of these versions. You would love to have all your clients and developed add-ins to be only in the latest version of Microsoft Dynamics NAV. However, we all know that is far from happening (At least for most of us).

Technical and functional consultants required to access these different versions all the time. So what is the best way to manage these different versions by keeping the fact of easy access? 

Is the best way to install all the versions on one big server? If so next question to answer is how to manage shared resources and conflicts? or to have virtual machines per each version of Microsoft Dynamics NAV? Once again running into a resource issue. 

What is the best way forward? for me, the answer is  Docker and Containers!

What is Docker? 
Docker is a containerization platform. In other words, Docker is a software platform which allows to build, test, and deploy applications with no time. 

The key benefit of Docker is that it allows users to package an application with all of its dependencies into a standardized unit for software development, Shipment, and Deployment. This standardized unit is called as containers. 

Docker was first released in the year 2013 and it was developed by Docker. 

What is the Container?
A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.

Container images become containers when they run on Docker Engine (During runtime). Containers are available for both Linux and Windows-based applications, the containerized software will always run the same, regardless of the infrastructure. 

Containers provide a higher level of isolation. Which means each container on Docker has its own registry, file system, network layer with its very own published ports and memory space. 

Are Containers and Virtual Machines are the same?
In a way, Docker and Containers are a bit like virtual machines, but unlike virtual machines rather than creating a whole virtual operating system, Docker allows applications in the container to use the same kernel as the system that they are running on. This means container should only need to have things which are not available on the host computer. This allows containers to be lightweight and also to provide a good performance boost. 

Containers run on total isolation and this allows you to run multiple instances of containers side by side without any conflicts. Only you will know that you are working on multiple container instances at the same time. 

Another advantage of containers is they are instant on, just like your TV. Whan, you run a container it does not have to go through all the initializations like normal computers, they know where to pick it up from. Containers also eliminate environment inconsistencies and the "works on my machine" problem by packaging the application, configs, and dependencies into an isolated container.

Is Microsoft release Docker images for Dynamics NAV?
YES! Microsoft does release Microsoft Dynamics NAV Container images to public Docker Hub.

How can a Containers be helpful to a NAV developer?
If you want to work and test your code on different versions of Microsoft Dynamics NAV, then Docker containers are the best solution. You do not have to create and configure different VMs to develop and test your code. Once you download the Container Image from Docker Hub you can easily clone the image and setup multiple instances within minutes. 

How can I get started with Docker and Containers?
Stay tuned for my next blog post, or if you are in a hurry then read Freddys blog. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

02 July 2018

Third consecutive year as a Microsoft Most Valuable Professional (MVP) - Business Applications

Third consecutive year as a Microsoft Most Valuable Professional.

It is a great honor to receive the Microsoft Most Valuable Professional (MVP) award. 

Thank you, everyone, for helping me out on this great journey. 

Thank you and Regards,
Tharanga Chandrasekara
Read more »

09 May 2018

Dynamics 365 Saturday - Melbourne 2018

I will be taking the stage this Saturday with Wagner Silveira at Dynamics 365 Saturday - Melbourne to talk about "Richer integration with logic apps for Microsoft Dynamics NAV and Dynamics 365".

Join us.

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »