Companial helped us to develop it and make it more adaptive to various updates and versions of Business Central.Leer más
Technical Code Changes in Microsoft Dynamics 365 Business Central 2022 Release Wave 2
Wednesday, November 9, 2022
Reading time: 8 minutes
October 1st was the official release day of Microsoft Dynamics 365 Business Central 2022 Wave 2 (version 21). You can review the list of new and planned functionality and the list of functionality that has been moved, removed, or replaced by Microsoft. Along with newly introduced and changed functionalities, a lot of code changes have been made, which I will review in this blog post. These include:
In the application, the new APIs are available for financial parts (currently in a Beta version only):
The new APIs will help you connect other applications to Business Central. In addition, in the Page Inspector, the field length has been added (see text/code field length). It is a small change that will help developers find bugs.
Developer experience changes
In Business Central version 21, changes are made in the launch.json file in VS code. For example, when trying to export Excel files and running the debugger, the application would quickly break on an error because the app will try functions that don’t work in all environments. This happens in a Try function. Before this version, you could only choose ‘yes’ or ‘no’ for break on an error. Now you can define it as ‘ExcludeTry’, and you will no longer break on Try functions.
And the same change was applied for the RecordWrites. If you enter data in a new record, you can now exclude write actions to temporary files, because in many cases these temporary files are less interesting. There is also the option to switch it back on again.
In the app.json file, in ResourceExposurePolicy, some of the default values have changed and a new setting is available.
In addition, in the app.json file, the new feature is automatically available in new projects saying that you can no longer use ImplicitWith statements. This is mainly used on pages.
From now on, when coding and writing fields in a table, the primary key fields of that table are shown in Intellisense windows. This helps you to find out which fields are necessary for creating a new record. Also, if you hover over the definition with the mouse, it will show you that the field is in the primary key and in which order the fields are arranged.
In addition, in Business Central version 21, many changes have been made in Permissions. There is a new action to generate Permissonset Objects. Also, in VS Code you can now have Code Actions across objects and projects. This is a VS Code option to change code in the objects automatically. Previously, these were limited to objects that you were currently in. But now, it is possible to have code actions that change multiple objects at the same time, and even change projects at the same time if these projects are linked.
Also, you can now see which tables are locked when you are debugging the process and you can view the executed code in the snapshot cell if you download the snapshot from the user-performed action. You will be able to see which code was executed in the tree so you do not have to look into all the code to find out.
Changes to the Business Central UI
In Business Central version 21 we have a modern action bar with split buttons and custom actions.
As you can see in the action bar screenshot above, there is a split button, a vertical bar, and a down arrow. This differs from the actions on the other hand, which do not have a vertical bar.
In this case it is not a split button, it’s a legacy-style menu.
Besides that, there is also a legacy List View. These are the Views available on your Role Center. A while ago Microsoft created a new object type called ‘View’. These Views are supposed to replace the List Views. Currently, both of them are shown on your Role Center, but in the future, the legacy List Views will be hidden. Now the new Views is an optional feature in Feature Management, and you can switch that on if you wish.
Also, now we have Power Automate on all pages, and you can have your automation flows available on any page that you’d like.
AL language changes
In Business Central version 20, the Inherent Permissions in AL language, which I introduced in the previous blog post, were only available in an On-Premises environment. Now, Inherent Permissions are also available for cloud, and there is an extra option to make it available on entitlements.
We also have the modern action bar in the AL language with the following:
The other change was made to ApplicationArea, which became the default. Previously, if you created a page in Business Central, for each part of that page, for every field and every button, you had to define the ApplicationArea. In many cases, this ApplicationArea would be the same value for all the fields or buttons. But now you can define the default ApplicationArea for object on the page, instead of defining it on each separate object. And you only have to change it on the fields or on the action if it is different from the page’s default area.
If you are creating CalcFields or FlowFields in Business Central version 21, there may be cases where you would like to apply a filter to a value, for example, for a field number. In the past, you had to use field numbers, but now you can also use the object name instead of the number.
Also in the latest version, if you read the records from the database, that record can be modified by other users while you are working on it. Now you have the option to compare the RowVersion of a record that you have in memory as a developer with the RowVersion in the latest version of your database. Based on that, you can decide whether you want to reread your data or update something.
Faster upgrades using DataTransfer are now available. If you are doing an app upgrade where you introduce a new table which replaces the old table, it may happen that you need to copy a lot of data from the old table to the new table. Until now, the only way to do that was to read all the rows of data into the application, make changes if required, and then write them to the new table. If there were one million records, you would have one million read actions and one million write actions, which is very time-consuming. Now, you have a new object type called DataTransfer, which you can use in Upgrade CodeUnits. DataTransfer allows you to move the data not through the application server, but directly on the SQL server. The SQL server is much more suited for such actions, allowing you to up data transfer by large amounts.
In addition, in the new Business Central version, OData Web Services have been updated and now support ByRef and XMLPort parameters.
One other AL language change, which is currently available for the development environment (not for production yet), is an aggregation of G/L Entries for posting. In a lot of localizations, because of the way G/L Entries were written when you were posting a sales order or a general ledger, the aggregation was different. You could not change that as a developer because it required a change of the Primary Key in the table, which you cannot do through AL. Now there is a solution for that where developers can write their own posting routines for using their aggregation.
A while ago Microsoft presented the Al:Go! for GitHub tool which helps developers start a DevOps process. If you are using different tools, such as Azure DevOps, you have to do a lot of configuration yourself, whereas Al:Go! does a lot of that automatically. With Al:Go! for GitHub, Microsoft’s target is to fulfill 100% of the needs for 90% of the customers. The difference between this Al:Go! version and the previous version is that now you can include your test scripts, meaning you can run automated tests using Al:Go!. In addition to that, you can now automatically publish your app on Microsoft AppSource if you have it already there.
The other change was made in the admin center API, where you can manage your customer’s environment through PowerShell or through an API. Now you can use S2S authentication. If you need to do modifications for many tenants at the same time, you can authenticate once as a service and then use that authentication for all your customers.
In the previous Business Central versions, in some cases when apps were installed in an environment, issues arose because the compilation check would be done against the latest version of the AppSource app that your customer has installed, instead of looking at the actual version that the customer has. Now, if you install an AppSource app and you compile your modification in a customer environment, it will compile based on the actual version of your AppSource app.
In the new Business Central version, we can now link the Entitlements to Permissions, which is a start for monetization in the AppSource. You can start setting it up in AppSource now, but the actual monetization will be available early next year.
There is also now a Power BI app for telemetry you can download, which will provide a nice overview of the telemetry that you have received from your customers, and where you can drill down in a lot of environments.
Companial upgrade options for Dynamics NAV/365 Business Central
If you’d like to find out more about the technical, functional, and administrative platform enhancements of the latest Dynamics 365 Business Central release, and see the live demo, watch the webinar on this topic here. You can also visit our website and find out how we can help Dynamics Partners to upgrade and maintain solutions in Dynamics 365 Business Central, or download the Companial e-book and learn more about Dynamics NAV/365 Business Central upgrade options.