28 February 2019

Call a Microsoft Dynamics 365 Business Central function through a Web Service : SOAPAction

Today I did some work with a Logic Apps and one of the requirement was to call a Business Central function through a Web Service. 

I normally use Postman to simulate requests, export the collection and use that to create the Logic App connector. 

Codeunit which I published as a web service had few functions exposed. I wanted to call one of those functions with values passing in and read the return value. 

If I just call (POST) Web Service with the SOAP Envelope (Like below image) it will just return the WDSL. Not the result I was expecting. 

Header :

SOAP Request and Response:

However, SOAP UI return the value I was expecting it to return. 

How that can be possible?  We looked into the "HTTP log" of the SOAP UI, and we saw SOAPAction is defined and its pointing to the function I want to call. 


I did the same thing in Postman and it worked. Below is my request header and you can notice that I add "SOAPAction" to the header. 
If you didn't define the "SOAPAction" in the request header, the result will bring back the WDSL regardless of your SOAP Envelope. 
I use the postman request to create my HTTP request in Logic App. There is a much easy way of doing this in Logic App with the help of custom connector. I will share those details in another day from a new blog post. 

** 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 »

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 2.3.4.500 -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. 


Limitations
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 2.3.4.500 -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.


Enjoy!

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   
 }  
 $ResultingObject.Count  
 #Display all tags:  
 $ResultingObject.name  

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 »