Dynamics 365 Business Central Extension Development

Dynamics 365 Business Central Technical Training — Part 2

Hello World Extension — AL Language — D365 Business Central Wave 2 | Dynamics NAV

8 min readNov 24, 2019

--

— Part 1

Before starting development for Dynamics Business Central, we need to understand a short but brief background of Dynamics NAV extension development. A stable release of Business Central was launched in 2018, before that it was known as Dynamics Navision.

In NAV, the CSIDE extension development model was very popular but Microsoft introduced AL programming language as well for extension development for NAV. Now, Microsoft is not upgrading CSIDE any more and it is deprecated to develop new extensions. I have already shared this information in my previous article. Click here to read a short introduction to Business Central and AL Language. So, we will use the AL Language to create the first hello-world extension of this series.

Environment Details

First, let’s understand the architecture Microsoft provides for Business Central production, staging and development purposes. I have demonstrated basic terminologies used in Professional work with a diagram of available environments.

I have presented in a tree-like structure to give a better understanding and a clear view of the environments.

Manual Deployment — Will be addressed with complete steps in later versions of this Story or in another short story

  • Azure Cloud: It deploys a complete environment including server, user interface, and database in azure cloud.
  • Local Deployment: It requires Windows 10 Pro or Windows Server with a docker installation.

Out-of-the-Box Environments

  • By default, when we register our trial or production account with Business Central, Microsoft provides one production environment only. In this tutorial, we will register for a Business Central account and will create a sandbox. This sandbox is available by default, but Microsoft does not deploy automatically with production tenant deployment on account creation. The purpose of deploying multiple sandboxes and the best way to update them is out of the scope of this article.

Trial Account Set up

Skip this step if you have already set up your account.

For learning purposes of Business Central extension development, there are two possibilities. The first option is to create an online trial account, valid for 30 days, and use the out-of-the-box available sandbox environment. Else deploy a sandbox locally without any trial account which is a docker based installation.

One important point to note here is that Business Central is still not launched worldwide. To get a complete list of supported countries/regions Click Here. If you reside in a country where it is not launched then you have to register the account with some other country.

1- Go to trials.dynamics.com → Select ‘Sales’ option and click ‘Sign up here’

2- Click ‘No, continue signing up’

3- Enter your personal information, If you are in a country where Business Central not supported please choose the United States or another country where it is launched

4- Enter the company domain information to create User

Once you complete all the steps, wait for the setup to complete and congratulations!. You have created the Dynamics Sales Trial Account. Now, go back to the trials.dynamics.com and this time select Business Central and enter the user account with which Sales account you created earlier a few moments ago. You may enter any digits in Phone Number and Get Started

Creating out-of-the-box Sandbox

Now, I assume the trial account has been set up and you have fresh Business Central installation ready to go and you have a screen like this after completing all the above steps. This is your production environment for Business Central.

Now Click on the search icon located at the top-right menu bar of Business Central and search ‘Sandbox’. Click the Sandbox Environment (Preview) → Create. Now, a copy of the production environment is created and we can start developing extensions using this newly deployed sandbox environment. This sandbox is purely a development environment a playground where we can deploy our extensions and test them before deploying to the UAT or Production environments.

Hello-World Extension — First AL Project

Now, sandbox environment has been set up and we need a code editor, VS Code is the only editor available to develop extensions. To get started with a bare minimum, we need an AL Language extension installed in VS Code. Search AL Language in VS Code extensions and install it.

AL Language Extension for VS Code
AL Language Extension for VS Code

Time has come to start extension development. Press Ctrl + Shift + P on Windows to open the VS Code command palette and search AL: Go!. Name your project and select Cloud Sandbox and it will automatically configure launch.json file in the project accordingly. That’s it. A new hello-world project is ready to deploy on a cloud sandbox account.

AL Project Environment Configuration
AL Project Environment Configuration

Even if you press escaped after creating the project or for any reason was not able to configure the environment at the time of project creation it’s normal. Just goto the launch.json file and click Add Configuration Button appearing at bottom of the file and select cloud Sandbox this time. Leave the default configuration as it is. It’s enough to get started.

Exploring Project Structure and Files

Let’s explore the files and folders in the boilerplate Hello World code generated by AL Language upon creating a new project.

Project Structure: Files and Folders
Project Structure: Files and Folders

1- Microsoft_System Application_15.0.36560.0.app: This file is named according to the Application version number of Business Central and contains Application metadata.

2- Microsoft_System_15.0.36510.0.app: This file is named according to the Platform version number of Business Central and contains platform related metadata.

3- launch.json: It is used to add configurations of cloud and local tenants for extension deployment.

4- app.json: We can configure the publisher’s name, starting page of Business Central, ID Ranges of AL Language elements, and much more.

5- HelloWorld.al: This file contains the actual hello word extension code.

Note: We will not modify the first two files for any purpose.

Understand HelloWorld.al Auto-Generated Code

First, understand what code objects are present in Business Central which can be used in AL Language for development.

Code Objects:

  • Pages
  • Tables
  • Reports
  • Queries
  • Codeunits
  • XMLPorts
  • Profile
  • Control Add-In

So, here in this project, we are extending the Customer List page with PageExtension object. Each object in the AL Language extension must have an ID. ID range is defined in the app.config file present in the project discussed above in the ‘Exploring Project Structure and Files’ section. There is a wide variety of triggers available to which custom code can be hooked. So, in this example we are using the OnOpenPage() trigger by calling Message function every time Customer List Page opens. In AL Language, functions’, loops’, and scope’ blocks start with ‘begin’ and finish with ‘end’ keyword. Please find my commented code below to understand better.

Extension Deployment To Sandbox

Before deploying extension to the server we need to download symbols. Now, in Platform 15, Business Central has been modularized into System and Base app. So, we need to download symbols for both modules to create extensions for Business Central. By default, when we created a project the AL Language extension added two files in .alpackages folder, just go and delete them and open command pallet by Ctrl + Shift + P and run AL: Download Symbols. It will prompt to enter the credentials, please enter the same with which you create User Id while registering the trial account.

It will create your platform-specific files in the .alpackages folder and will take a few minutes to download the symbols. Now, the project is ready to build and publish without any additional modifications to the project. Just check ‘.alpackages’ folder, this command has created another extra file that was not there before. Now, the extension is properly modularized into base, system, and platform.

Here comes the role of Rapid Application Development (RAD). There are many ways to deploy the extension code to the server (local/cloud). RAD allows incremental push of code rather than deploying complete extension every time building and publishing the app. Before using incremental push (RAD Feature), it is required to use full push feature once at least for every new extension. There are shortcuts available for possible ways to deploy and debug the extension over server:

  • Ctrl + Alt + F5: Incremental Push
  • Alt + F5: Incremental Push and Debug Code
  • Ctrl + F5: Full Push — before using RAD features
  • Ctrl + Shift + B: Only Build the code
  • Ctrl + Shift + F5: Debug without publishing, it means you will be debugging the last extension deployment.
  • F6: Publish and open in Designer

We will use Ctrl + F5 to full publish the extension for the first time. This will open the sandbox environment in your default browser with HelloWorld deployed extension. Now, you must be able to see a Hello World message in the browser like this:

Woohoo! Yalla! You have created your very first extension for Dynamics Business Central with high-level knowledge of the Business Central professional working environment. In the next post, we will add source control to the project and will continue with more advanced topics for creating extensions in Business Central. Please ask questions if you need any suggestions or if you phase any issues or get stuck at some point while following the tutorial. Thanks. Please follow me on medium to stay tuned with my new posts related to Business Central or even on different Microsoft Dynamics 365 products.

References:

https://businesscentral.dynamics.com

#microsoft dynamics business #microsoft dynamics 365 business central #microsoft dynamics 365 bc #microsoft business central #microsoft dynamics 365 business #dynamics 365 small business microsoft dynamics for small business #ms dynamics business central #ms d365 bc #BusinessCentral #Development #Technical #D365 Business Central # D365 BC #Dynamics365 BC #Dynamics365 Business Central #C/AL Programming #AL Langauge #Extension Development #D365 BC Wave 2 #D365 Business Central Wave 2

--

--

D365 Business Central and F&O Developer | Certified Dynamics Developer | Talent | Power Platform | WordPress | Angular