Monthly Archives: May 2020

AL Development in Business Central – Part 4 More in detail about launch.json and app.json

In your Business Central workspace some configuration files were created and an example AL file (see part 3). In this post we will get into more detail about the configuration files (JSON based).

The AL workspace contains configuration files:

  • launch.json
    • In this file serveral settings are defined like: servername, server instance and startupobject.
    • Located in the .vscode folder
    • Controls debug environment
  • app.json
    • This configuration file serves as a manifest and contains information about your app.
    • Located in the workspace root

An example how the file launch.json looks like by default in BC16:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "al",
            "request": "launch",
            "name": "Your own server",
            "server": "http://localhost",
            "serverInstance": "BC160",
            "authentication": "Windows",
            "startupObjectId": 22,
            "startupObjectType": "Page",
            "breakOnError": true,
            "launchBrowser": true,
            "enableLongRunningSqlStatements": true,
            "enableSqlInformationDebugger": true
        }
    ]
}

Some more important launch.json settings explained:

SettingDescription
authenticationWindows, AAD (Azure Active Directory) or UserPassword
serverThe url of your server
serverinstanceThe name of the server instance running on your server (BC160 in my case)
startupObjectTypeSpecify the object type. This could be a page or table. In BC16 you also have the possibility to specify Report or Query.
startupObjectIdThe object ID to start when you press [F5]

An app.json looks like this by default:

{
  "id": "45a1ebaf-28ba-4c4b-8b33-24a4df88f1f4",
  "name": "ALProject1",
  "publisher": "Default publisher",
  "version": "1.0.0.0",
  "brief": "",
  "description": "",
  "privacyStatement": "",
  "EULA": "",
  "help": "",
  "url": "",
  "logo": "",
  "dependencies": [
    {
      "id": "63ca2fa4-4f03-4f2b-a480-172fef340d3f",
      "publisher": "Microsoft",
      "name": "System Application",
      "version": "16.0.0.0"
    },
    {
      "id": "437dbf0e-84ff-417a-965d-ed2bb9650972",
      "publisher": "Microsoft",
      "name": "Base Application",
      "version": "16.0.0.0"
    }
  ],
  "screenshots": [],
  "platform": "16.0.0.0",
  "idRanges": [
    {
      "from": 50100,
      "to": 50149
    }
  ],
  "contextSensitiveHelpUrl": "https://ALProject1.com/help/",
  "showMyCode": true,
  "runtime": "5.0"
}

Some app.json settings explained:

SettingDescription
nameThe name of the app
publisherThe publisher of the app
platformVersion of the dependent platform. Version 16 is Business Central 2020 Wave 1.
runtimeThe version of the runtime. At the moment of writing we have 5 major versions of the AL Runtime:
1.0 Business Central April 2018 release
2.0 Business Central October 2018 release CU 2
3.0 Business Central April 2019 release
4.0 Business Central 2019 release wave 2 (BC15)
5.0 Business Central 2020 release wave 1 (BC16)

More detailed information about the JSON configuration file is available here on Microsoft Docs.

AL Development in Business Central – Part 3 (Connect, Download symbols, Extend a page and Publish as extension)

Now that we have VS Code with the required AL Extension we can now connect to the BC environment.

Open VS Code

Pres [F1] in VS Code and type AL:Go! and press the [Enter] key

AL: Go! in VS Code

Accept the default path by pressing [Enter]
Select the target platform ‘5.0’ Business Central 2020 release Wave 1:

Target platform list in VS Code

A new project has now been created (with an app.json file). Select ‘Your own server’ since my posts are based on an on-prem environment, but if you are using BC in the cloud select: Microsoft cloud sandbox (out of scope in this post). Now other files are created in your ‘project folder’, these 2 are the most important: launch.json and settings.json
Locate and click launch.json in the explorer (left pane). You now see the contents of this file. Our default BC installation uses Windows authentication so change the launch.json:

"authentication": "UserPassword", 

to

"authentication": "Windows",

and save the file.

Now download the symbols. Press [F1] and type the command: AL: Download Symbols and press [Enter]. I received an error

Error: Could not connect to the server. Please verify that:1. The server is started.2. The development endpoint is enabled (DeveloperServicesEnabled server setting).3. The service name matches the one specified in the URL.4. The port number matches the one specified in the URL (DeveloperServicesPort server setting).5. The protocol matches the one specified in the URL (DeveloperServicesSSLEnabled server setting), and that a trusted certificate is used in case of an SSL connection.

I enabled DeveloperServices on the service, saved the change and restarted the service and now I was able to download the symbols:

Enable Developer Service Endpoint in the Busines Central Administration Tool

If you couldn’t download the symbols don’t proceed. All further steps will fail until you resolve the issue. If the symbol download was successful you should see a message in the output pane:

Open HelloWorld.al in the VS Code explorer (Left Pane) and change the message to something else.
Publish the file (which in fact is a page extension). Press [F5]. In my scenario the publish failed due to an error:

Error: Could not open the specified startup page. Please check that the server configuration key PublicWebBaseUrl has been properly set.

So after checking this key I filled in the WebBaseUrl saved it and restarted the BC service:

Tip: it’s also possible to change this setting by using PowerShell.

Web Client Base URL setting in the Administration Tool

The publish still errored. So I closed VS Code and published it again. It now executed without any problems and our first extension is published:

You will see this message (extension) when you open the customer card in Business Central