- Get started with Dynamics 365
Stay on top of the latest features and releases
FastTrack your deployment
Speed up your rollout with personalized tools, resources, and best practices
Find the right eLearning courses for your role
Resources for people with disabilities
Learn how Dynamics 365 supports your GDPR compliance journey
- Get started with Dynamics 365
The AL developer environment is evolving with frequent updates. To stay up to date on the latest information and announcements, follow us on the Dynamics NAV Team Blog.
Development in AL
Extensions are a programming model where functionality is defined as an addition to existing objects and defines how they are different or modify the behavior of the solution. This section explains how you can develop extensions using the development environment for Dynamics 365 Business Central.
If you are new to building extensions, we recommend that you read this document to get an understanding of the basics and terms you will encounter while working. Next, follow the Getting Started with AL to set up the tools.
If you are looking for the C/SIDE documentation, visit our Dynamics NAV library.
Understanding objects in the development environment
All functionality in Dynamics 365 Business Central is coded in objects. The extension model is object-based; you create new objects, and extend existing objects depending on what you want your extension to do. Table objects define the table schema that holds data, page objects represent the pages seen in the user interface and codeunits contain code for logical calculations and for the application behavior. These objects are stored as code, known as AL code, and are saved in files with the
.al file extension. The AL Language extension also supports the multi-root functionality which allows you to work with multiple AL folders within one workspace. For more information on how to group a set of disparate project folders into one workspace, see Working with multiple AL project folders within one workspace.
A single .al file may contain multiple objects.
There are two other special objects which are specifically used for building extensions. Table extension objects and page extension objects are used for defining additive or overriding changes to table or page objects. For example, an extension for managing a business that sells organic food may define a table extension object for the Item table that contains two additional fields,
Produced Locally. The
Produced Locally fields are not usually present in the Item table, but through the table extension these data fields will now be available to store data in and to access from code. You can then use the page extension object to display the fields that you added to the table object.
Extension objects can have a name with a maximum length of 30 characters.
You have several options for creating new objects with the AL Language extension for Visual Studio Code. For more information about the objects that you can create for your extension, see AL Development Environment.
Developing extensions in Visual Studio Code
Using the AL Language extension for Visual Studio Code, you will get the benefits of a modern development environment along with seamless publishing and execution integration with your Dynamics 365 Business Central tenant. For more information on getting up and running, see Getting Started with AL.
Visual Studio Code and the AL Language extension lets you do the following tasks:
- Create new files for your solution
- Get assistance with creating the appropriate configuration and setting files
- Use code snippets that provide templates for coding application objects
- Get compiler validation while coding
- Press F5 to publish your changes and see your code running
For more information, see Visual Studio Code Docs.
If you have previous experience working with the C/SIDE development environment and need an overview of some of the changes between the two development environments, see Differences in the Development Environments.
The Designer works in the client itself allowing design of pages using a drag-and-drop interface. The Designer allows building extensions in the client itself by rearranging fields, adding fields, and previewing the page design. For more information, see Using Designer.
Compiling and deploying
Extensions are compiled as .app package files. The .app package file can be deployed to the Dynamics 365 Business Central server. An .app package contains the various artifacts that deliver the new functionality to the Dynamics 365 Business Central deployment as well as a manifest that specifies the name, publisher, version, and other attributes of the extension. For information about the manifest, see JSON Files.
Submitting your app
When all development and testing is done, you can submit your extension package to AppSource. Before you submit the extension package, we encourage you to read the checklist to help facilitating the validation. For more information, see Checklist for Submitting Your App.
We’re pleased to announce the March update of the Developer Preview. We have been working hard on improving the capabilities of the toolset as well as fixing incoming issues reported by you. Below you can see the changes that we’re announcing for this update. The preview is already available if you sign up for the Ready to Go program. Read more at http://aka.ms/readytogo.
After April 2nd the build will become public and you can get it through http://aka.ms/bcsandbox.
Please note, that the improvements announced in this blog post are not available in Dynamics NAV 2018 and the following cumulative updates of Dynamics NAV 2018.
Static Code Analysis
Specifying “al.enableCodeAnalysis”: true in your settings will enable static code analysis for AL projects. Three analyzers have been implemented that will support general AL coding guidelines, AppSource, and per-tenant extension analysis. Analyzers can be individually enabled by specifiying them in the al.codeAnalyzers setting.
You can customize how the diagnostics generated by the analyzers are reported by adding a custom ruleset file <myruleset>.ruleset.json to the project and specifying the path to it in the “al.ruleSetPath” setting.
“al.ruleSetPath” : “myruleset.ruleset.json”
Using the snippets truleset and trule will get you started quickly.
For more information, see Using the Code Analysis Tool.
Help for new pages
When creating new Pages, Reports, and XMLPorts in Extensions V2, it is now possible to specify the help link that will be used when the user presses the Help button in the user interface.
You can do this by using the property HelpLink on Pages, for example:
page 50100 MyPageWithHelp
HelpLink = ‘https://www.github.com/Microsoft/AL’;
And by using the property HelpLink on the request page of Reports and XmlPorts:
report 50100 MyReportWithHelp
HelpLink = ‘https://www.github.com/Microsoft/AL’;
For more information, see Adding Help Links.
Creating Role Center Headlines
You can set up a Role Center to display a series of headlines, where headlines appear one at a time for a predefined period of time before moving to the next. The headlines can provide users with up-to-date information and insights into the business and their daily work.
For more information, see Creating Role Center Headlines.
Improved experience for event subscribers
We improved the snippets and IntelliSense around event subscribers, for both the attribute arguments and the method parameters. This is now working for trigger events, integration and business events. In case of business and integration events, the suggestion of the method parameters is made based on the attributes of the event publisher in order to know if the global variables and/or the sender should also be suggested.
Here is what it looks like to subscribe to an integration event when using the snippets:
Here is what it looks when writing the event subscriber from scratch:
Working with data?
You can now inspect the contents of a table when you publish an AL project (F5 and Crtl+F5) from Visual Code. Simply modify the launch.json file of the project to include the “startupObjectType=”table” and “startupObjectId”=” settings, replacing with the ID of the table that you want to see. The table will display in client as read-only.
From the client, you can also view a specific table by appending the URL with “&table=”, such as:
For more information, see Viewing Table Data.
Choose your cue layout on Role Centers
We now offer a wide layout option for cues. The wide layout is designed to display large values and gives you a way emphasize a group of cues. When set to the wide layout, a cue group will be placed in its own area, spanning the entire width of the workspace.
For more information, see Cues and Action Tiles.
As usual we encourage you to let us know how you like working with these additions and keep submitting suggestions and bugs. You can see all the filed bugs on our GitHub issues list (https://github.com/Microsoft/AL/issues).
For a list of our previous blog posts, see the links at the end of this post.
AL is the programming language that is used for manipulating data (such as retrieving, inserting and modifying records) in a Dynamics 365 for Finance and Operations, Business edition and Dynamics NAV database, and controlling the execution of the various application objects, such as pages, reports, or codeunits. More…
Converting from C/AL to AL can be a bit of a hassle:
- First you need to open den Development Environment
- Then filter the objects that needs converting
- Export the objects to a txt file in a folder
- Then Run the Txt2AL.exe
- Lastly import them in the workspace
The Script can be downloaded here:
With the general availability of Microsoft Dynamics NAV 2018 in the first week of December 2017, the new and Modern development environment experience becomes more and more used by developers; side by side with the C/SIDE development environment.
Working with a standard CRONUS database is pretty easy, while every developer would like to give it a spin with their own customized database. In this scenario, it is paramount to have the appropriate symbols generated in order to be successfully pulled out by AL Extension command in Visual Studio Code and develop a custom extension against a proper customized source database.
Installing CSIDE Development Environment side by side with Modern Development Environment is duly described in the docs, as well as how to generate / re-generate symbols. For more information, see https://docs.microsoft.com/en-us/dynamics-nav/developer/devenv-running-cside-and-al-side-by-side.
Here are a few tips that can be helpful when generating symbols.
As interacting with WebServices, especially JSON/REST based WebServices, becomes more and more important, it was very good to see that the new NAV dev environment made it quite easy to do exactly that a couple of releases ago. After reading AJ Kauffmann’s excellent blog post on that topic, I had the idea to auto-generate that code based on a JSON file, so that you no longer need to write a single line of code to get a working base structure. With release 2.3.0 of my VS Code extension this is now possible!
One of the things that has changed when you are building V2 extensions for a cloud environment is that you cannot access most functions that work with physical files.
This presents a bit of a challenge when it comes to working with the media and media set field types, as the typical approach is to have an import and export function so that a user can get pictures in and out of the field.
An example of this is the Customer Picture fact box that’s on the Customer Card:
As you can see, the import and export functions in C/Side leverage the FileManagement codeunit in order to transfer the picture image to and from a physical picture file. These functions are now blocked.
So…..we have got to take another approach. Enter streams.
Using the in and out stream types we can recreate the import and export functions without using any of the file based functions.
An import function would look like the following. In this example, the Picture field is defined as a Media Set field.
local procedure ImportPicture(); var PicInStream: InStream; FromFileName: Text; OverrideImageQst: Label 'The existing picture will be replaced. Do you want to continue?', Locked = false, MaxLength = 250; begin if Picture.Count > 0 then if not Confirm(OverrideImageQst) then exit; if UploadIntoStream('Import', '', 'All Files (*.*)|*.*', FromFileName, PicInStream) then begin Clear(Picture); Picture.ImportStream(PicInStream, FromFileName); Modify(true); end; end;
The UploadIntoStream function will prompt the user to choose a local picture file, and from there we upload that into an instream. At no point do we ever put the physical file on the server. Also note that the above example will always override any existing picture. You do not have to do this as media sets allow for multiple pictures. I’m just recreating the original example taken from the Customer Picture page.
For the export we have to write a bit more code. When using a Media Set field, we do not have access to any system function that allows us to export to a stream. To deal with this all we need to do is loop through the media set and get each of the corresponding media records. Once we have that then we can export each of those to a stream.
That would look like this:
local procedure ExportPicture(); var PicInStream: InStream; Index: Integer; TenantMedia: Record "Tenant Media"; FileName: Text; begin if Picture.Count = 0 then exit; for Index := 1 to Picture.Count do begin if TenantMedia.Get(Picture.Item(Index)) then begin TenantMedia.calcfields(Content); if TenantMedia.Content.HasValue then begin FileName := TableCaption + '_Image' + format(Index) + GetTenantMediaFileExtension(TenantMedia); TenantMedia.Content.CreateInStream(PicInstream); DownloadFromStream(PicInstream, '', '', '', FileName); end; end; end; end;
We use the DownloadFromStream function to prompt the user to save each of the pictures in the media set. As in our first example, there are no physical files ever created on the server, so we’re cloud friendly!
You may notice that I use the function GetTenantMediaFileExtension in the export example to populate the extension of the picture file. Since the user can upload a variety of picture file types, we need to make sure we create the file using the correct format.
The function to do this is quite simple, however there is no current function in the product to handle it, so you’ll have to build this yourself for now. Hopefully in the near future this function will be added by Microsoft.
local procedure GetTenantMediaFileExtension(var TenantMedia: Record "Tenant Media"): Text; begin case TenantMedia."Mime Type" of 'image/jpeg' : exit('.jpg'); 'image/png' : exit('.png'); 'image/bmp' : exit('.bmp'); 'image/gif' : exit('.gif'); 'image/tiff' : exit('.tiff'); 'image/wmf' : exit('.wmf'); end; end;
Welcome to our update for the Developer Preview; the December update. As usual, we’ve fixed a lot of issues reported by you, for more information view the list of fixed issues, In addition to that we’re announcing the following changes as you can see listed below. To jump directly to an updated image go to the Azure Gallery sign up at http://aka.ms/navdeveloperpreview.
The AL Formatter
The AL Language Visual Studio Code extension now offers the option of automatically formatting your source code. The auto-formatter can be invoked to format an entire AL document or a pre-selected range.
- In an existing project, open the document that you want to format, right-click inside the document, and then choose Format Document.
- To format a range, open the document that you want to modify, select the specific range to format, right-click it, and then choose Format Selection.
Earlier blog posts: