Sunday, January 13, 2019

How to Use app.json & launch.json in Business Central

How to configuring app.json & launch.json?

Both lauch.json & app.json in Business Central is backbone / foundation / manifest / core of extension / etc. Both are very important and by default created with minimum & mandatory values when we create a new project .

launch.json file contains information about the server that the extension launches on:

launch.json is automatically created when we create a new project in AL. Below are the example / sample of default file key & values:

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

There are other keys & values (nodes / token) provided to configure as per requirement and for the other purposes.

Below are setting details from Microsoft Docs which is describing, how we will publish our extension on local server (on premise) and on cloud:

Publishing Extension to Local Server (On Premise Deployment):


Setting
Mandatory
Value
Example
name
Yes
"Publish to your own server"
MyBCServer
type
Yes
Must be set to ".al". Required by Visual Studio Code.
al
request
Yes
Request type of the configuration. Must be set to "launch". Required by Visual Studio Code.
launch
server
Yes
The HTTP URL of your server, for example: "http://localhost|serverInstance"
http://localhost
port
No
The port assigned to the development service.
7049
serverInstance
Yes
The instance name of your server, for example: "US"
BC130
authentication
Yes
Specifies the server authentication method. Currently, AAD authentication is supported only for Dynamics 365 Business Central sandboxes. AAD authentication cannot be used for on-premise servers.
Windows
startupObjectType
No
Specifies whether the object to open after publishing is a Page type ("Page") or Table type ("Table") object. The default is "Page".
Page
startupObjectId
No
Specifies the ID of the object to open after publishing. Only objects of type Page and Table are currently supported.
22
schemaUpdateMode
No
Specifies the data synchronization mode when you publish an extension to the development server, for example: "schemaUpdateMode": "Synchronize Recreate"
The default value is Synchronize. For more information, see Retaining table data after publishing. This feature is not supported in Dynamics NAV.
Usually we leave as default.
breakOnError
No
Specifies whether to break on errors when debugging. The default value is true.
ture (default value)
breakOnRecordWrite
No
Specifies if the debugger breaks on record changes. The default value is false.
Usually we leave as default.
launchBrowser
No
Specifies whether to open a new tab page in the browser when publishing the AL extension (Ctrl+F5). The default value is false. If the value is not specified or set to true, the session is started. If the value is explicitly set to false, the session is not started unless you launch your extension in debugging mode.
Usually we leave as default.

Publishing Extension to Cloud:


Setting
Mandatory
Value
Example
name
Yes
"Publish to Microsoft cloud sandbox"
SandBoxName
type
Yes
Must be set to ".al". Required by Visual Studio Code.
al
request
Yes
Request type of the configuration. Must be set to "launch". Required by Visual Studio Code.
launch
startupObjectType
No
Specifies whether the object to open after publishing is a Page type ("Page") or Table type ("Table") object. The default is "Page".
Page
startupObjectId
No
Specifies the ID of the object to open after publishing. Only objects of type Page and Table are currently supported.
22
tenant
No
Specifies the tenant to which the package is deployed. If you specify multiple configurations, a drop-down of options will be available when you deploy.
Tenant-Name

app.json files contains information about the extension:

app.json is automatically created when we create a new project in AL. Below are the example / sample default key & values:

{
   "id": "c8d3c095-f92b-4ca8-b426-2d5c3e7da96d",
   "name": "ProjectD365BC",
   "publisher": "Default publisher",
   "brief": "",
   "description": "",
   "version": "1.0.0.0",
   "privacyStatement": "",
   "EULA": "",
   "help": "",
   "url": "",
   "logo": "",
   "capabilities": [],
   "dependencies": [],
   "screenshots": [],
   "platform": "13.0.0.0",
   "application": "13.0.0.0",
   "idRange": {
      "from": 50100,
      "to": 50149
   },
   "runtime": "2.2"
}

There are other keys & values (nodes / token) provided to configure as per requirement and for the other purposes.

Below are setting details from Microsoft Docs which is describing, the app.json file contains information about extension that you are building, such as publisher information and specifies the minimum version of base application objects that the extension is built on. Often the app.json file is referred to as the manifest.

Below are detailed settings for app.json:

Setting
Mandatory
Value
Example
id
Yes
The unique ID of the extension. When app.json file is automatically created, the ID is set to a new GUID value.
"e2785bd8-1452-48bc-ade7-33c2ddb2b3d5"
name
Yes
The unique extension name.
ProjectD365BC
publisher
Yes
The name of your publisher, for example: NAV Partner, LLC
MyExtension
brief
No
Short description of the extension. (Mandatory, if required for AppSource submission)
My Extension
description
No
Longer description of the extension.
For testing internal
version
Yes
The version of the app package. (Mandatory, if required for AppSource submission)
1.0.0.0
privacyStatement
No
URL to the privacy statement for the extension. (Mandatory, if required for AppSource submission)
Usually left undefined.
EULA
No
URL to the license terms for the extension. (Mandatory, if required for AppSource submission)
Usually left undefined.
help
No
URL to the help for the extension. (Mandatory, if required for AppSource submission)
Usually left undefined.
url
No
URL of the extension package.
Usually left undefined.
logo
No
Relative path to the app package logo from the root of the package. (Mandatory, if required for AppSource submission)
Usually left undefined.
dependencies
No
List of dependencies for the extension package. For example: "dependencies": [ { "appId": "4805fd15-75a5-46a2-952f-39c1c4eab821", "name": "WeatherLibrary", "publisher": "Microsoft", "version": "1.0.0.0"}],
Usually left undefined. But must define if using any dependency (controll addins, etc.)
screenshots
No
Relative paths to any screenshots that should be in the extension package.
Usually left undefined.
platform
Yes
The minimum supported version of the platform symbol package file, for example: "11.0.0.0". See the Symbols for the list of object symbols contained in the platform symbol package file.
13.0.0.0 for Business Central
application
Yes
The minimum supported version, for example: "application": "11.0.0.0" (Note: Mandatory, if base application objects are extended or referenced. The AL package will be compiled against the application that is present on the server that you connect to. This allows you to write a single AL Language extension for multiple country versions as long as you do not depend on country-specific code. If you do depend on country-specific code you should only try to compile your app against a server set up for that country.)
13.0.0.0 for Business Central
features
No
To enable generation of the translation file, you must add a setting in the manifest.
"TranslationFile"
idRange
Yes
For example: "idRange": {"from": 50100,"to": 50149}. A range for application object IDs. For all objects outside the range, a compilation error will be raised. When you create new objects, an ID is automatically suggested.
As per extension series. For testing, usually leave with default.
idRanges
Yes
For example: "idRanges": [{"from": 50100,"to": 50200},{"from": 50202,"to": 50300}]. A list of ranges for application object IDs. For all objects outside the ranges, a compilation error will be raised. When you create new objects, an ID is automatically suggested. You must use either the idRange or the idRanges setting. Overlapping ranges are not allowed and will result in a compilation error.
Define in case of using different - different range. Basically for multiple reanges of object IDs.
showMyCode
No
This is by default set to false and not visible in the manifest. To enable viewing the source code when debugging into an extension, add the following setting: "showMyCode": true
TRUE
target
No
By default this is Extension. For Dynamics NAV, you can set this to Internal to get access to otherwise restricted APIs and .NET Interop. The Dynamics NAV Server setting must then also be set to Internal.
Internal
helpBaseUrl
No
The URL for the website that displays help for the current extension. The default URL is https://docs.microsoft.com/{0}/dynamics365/business-central.
Usually left undefined. Default value.
supportedLocales
No
The list of locales that are supported for looking up help. The value on the list is inserted into the URL defined in the helpBaseUrl property. The first locale on the list is default. An example is "supportedLocales": ["da-DK", "en-US"].
Usually left undefined. Default value.


For detailed explanation please read complete details on Microsoft Docs (Click Here)