Tag Archives: Development

A quick look into the upcoming major version in April 2021 (Business Central 2021 release wave 1) from the developer’s point of view

It is only four months since the last major version of the Business Central (2020 wave 2) has been released, and we can already look forward to another version that will be released in April.

Microsoft has already provided the list of planned and confirmed functionality (available here). Let’s look at some of the planned features that will be usable (or, at least available) for programmers.

Most useful changes for developers

Extensible reports

One of the most annoying things for customising in the AL language are definitely reports. Till now, to add own field to the existing report from the base app or another extension, there was no other way but to copy the report and do the change in this copy.

With the upcoming version, developers will be able to create a report extension objects. Using this extension object type, we will be able (at least) to add new fields to existing datasets and request pages.

In my opinion, this is one of the most critical changes and as so I will look at it in another article once it is available in public preview.

Returning of complex types from AL procedures

One of the greatest news is that with the new update almost every complex type (record, page, query, list, …) can be returned from a procedure. Let’s see an example:


 procedure GetSellToCustomer(): Record Customer
 var
   Customer: Record Customer;
 begin
   Rec.TestField("Sell-to Customer No.");
   if Customer.Get("Sell-to Customer No.") then
     exit(Customer);
 end;

As this is a big change and as it is something known and often used in almost any other language, I will look at it in details in the next weeks.

Ability to add own keys/indexes to base table/tableextension

To increase custom processes’ performance, Microsoft added support of adding own keys to original tables and tables from any extension.

Entitlement and PermissionSet objects

There will be new object types for better administration and security of user’s roles: Entitlements, PermissionSets and PermissionSetExtension.

PermissionSets (and PermissionSetExtension) are already familiar to anybody. However, in current versions of the Business Central, they are stored and managed directly in the Modern Client.

Entitlements is a new object type that will allow specifying, which objects are available for specific users based on their assigned license (Full, Team Member, …) or Azure Active Directory role.

Easier working with 1-D barcodes in report layouts

There are new fonts available to use in report layouts. These fonts allow generating one-dimensional barcodes. For now (2021/02) licensed fonts are as follow

Some of other improvements

  • Availability to specify report layout both using AL or directly in the Modern Client (so as developers, we can use the same report for more layouts dynamically)
  • Performance improvements to Role Centers. The content of the Role Center is loaded in a similar way to FactBoxes. That means that Role Centers are loaded part by part from top-level (from menus), and only the visible parts are loaded. For developers, that is the improvement that helps with the performance a lot as users will be able to use menu actions without waiting for bricks and other stats shown on the main page.
  • Interfaces can be obsoleted as any other objects (In my opinion, this is a fix, not an improvement…)
  • Lookups triggers will return record link of selected record instead of its name.
  • Many improvements to the extensibility of reservation management. I will cover this topic as a separate article in the upcoming weeks.

ALRM: AL ID Range Manager introduction

AL ID Range Manager is VS Code & Microsoft Dynamics 365 Business Central extensions made for developers who need to manage their object/field IDs across multiple projects (or in the multi-developers environment).

Source codes are available online on GitHub

The project was originally created as a part of our project for hackathon Coding4BC that took place in November 2020 (https://www.coding4bc.com).

Made by developers for developers.

D365 Business Central Bootcamp (16. – 17. 04. 2021)

UPDATE 21. 02. 2021: Event postponed from 05. – 07. 03. 2021 to 16. – 17. 04. 2021

The first 2021 Business Central technical conference is here. If you are interested in my blog and topics, please vote for my sessions to be available at the conference!

AL Language: Coding for performance

Microsoft brought much new functionality in the last versions to increase the performance of the system; however, the core of all usual performance problems are linked to the way, how extensions are developed. In this session, we will look in detail on the following topics: Table Extensions objects, Partial Records (Loaded Fields), Impact of table extensions on performance and on Programming patterns for performance.

AL Language: Enums & Interfaces

In this session, we will look at how to use enums and interface properly. Enums are full replacement of the Options data type and together with Interfaces can create a powerful, extensible environment.

AL ID Range Manager is available!

I am glad to announce that the very first version of AL ID Range Manager is available for everyone on Visual Studio Code Marketplace!

AL ID Range Manager is an extension for VS Code that helps with managing AL objects between developers who are working on the same project / within the same object license range. The source codes are available to everyone: https://github.com/TKapitan/ALRM-VSCode

Do you want to try it?

If you want to use this extension, just type “AL ID Range Manager” (or “Kepty” to list all my extensions) and select install like any other extension you are using.

To set up the extension before the first use, see README directly on my GitHub.

Let me know what you think! Do you have an idea, or have you found a bug? Please report it on the GitHub as an Issue.

Partial Records

Partial Records are a new capability of Business Central introduced in Business Central 2020 release wave 2. It allows specifying fields that should be loaded when accessing SQL based data.

How does it work? Without using partial records, Business Central normally load all data from the record even if only one of them is required. The partial records, developer specify which fields are needed and the Business Central than load only that fields.

This is especially (based on Microsoft notes) important when Tableextensions are used. In that case, each Tableextension is stored as a separate table on the SQL server and, when the data from this table are loaded, SQL server joins the primary table, extension table (and other extension tables if exist) using join. Although the join is done using primary keys, the query is still much more performance-intensive than the query that accesses only one table.

Related Functions

There are four related functions:

  • [Ok := ] Record.SetLoadFields([Fields: Any,…])
    • Using the function SetLoadFields we specify a set of fields that server should load from the database. Fields have to be specified before the record is retrieved from the database (similar as SetAutoCalcFields()).
    • If the function is called more than once, only fields specified within the last call are loaded.
  • [Ok := ] Record.AddLoadFields([Fields: Any,…])
    • Similar function to SetLoadFields that has one big difference: if the function is called multiple times, the new call does not reset fields that were already set (even if they were set using SetLoadFields).
  • Ok := Record.AreFieldsLoaded(Fields: Any,…)
    • Checks whether the fields specified as parameters are already retrieved from the database.
  • [Ok := ] Record.LoadFields(Fields: Any,…)
    • This function allows loading data from the data source that was not loaded when the last partial record was retrieved (because the field was not specified using SetLoadFields nor AddLoadFields).

More specifically

In the first part, I wrote that only specified fields are loaded when the row is fetched from the database; however, if the fields were not loaded (using SetLoadFields / AddLoadFields) and system needs their value, they are automatically fetched using Just-In-Time (JIT) mechanism.

When JIT loading occurs, the system automatically loads data using the primary keys of the current record. This fetch might fail if the record was changed (modified / renamed / deleted) since the original data was retrieved. And that is the reason why the function LoadFields exists – when JIT loading occurs automatically, there is no way how to resolve if the loading fails. With LoadFields developers can implement explicit error handling for these fails.

Example

The example below is from Microsoft Docs and shows how to use SetLoadFields. As is mentioned on the Docs, in this case, the example is nine times faster than the same code without the Partial Records functionality.

 procedure ComputeArithmeticMean(): Decimal;
 var
     Item: Record Item;
     SumTotal: Decimal;
     Counter: Integer;
 begin
     Item.SetLoadFields(Item."Standard Cost");
     if Item.FindSet() then begin
         repeat
             SumTotal += Item."Standard Cost";
             Counter += 1;
         until Item.Next() = 0;
         exit(SumTotal / Counter);
     end;
 end

Microsoft example

As this is a very different approach to developing custom functionalities, I will definitely check the performance with some advance example codes in some of the next articles.