Business Central 2024 wave 1 (BC24): Support for multiple extensions to same target and extensions and target in same app – Define extension objects in same app as their base object

Dynamics 365 Business Central

Hi, Readers.
The public preview for Dynamics 365 Business Central 2024 release wave 1 (BC24) is available. Learn more: Link.

I will continue to test and share some new features that I hope will be helpful.

In this post, I would like to talk about Support for multiple extensions to same target and extensions and target in same app. It is mentioned in AL Language extension changelog Version 13.0

Support for multiple extensions to same target and extensions and target in same app:

We have expanded the support for extension objects to help achieve better separation of concerns in large apps. The following changes have been made:

  • Extensions can now exist in the same app as their target.
  • Multiple extensions to the same target can exist in the same app.

For table extensions in the same app as their target, the fields and keys will be moved to the base table to prevent SQL-joins at runtime.

Since extension objects from a given app are applied on the target following the extension object ID, the following compiler validation was introduced:

  • The base object cannot reference members from extension objects.
  • Extension objects can reference members from other extension objects in the same app only if the other extension object has a lower object ID.
https://marketplace.visualstudio.com/items/ms-dynamics-smb.al/changelog

Business Central 2024 release wave 1 (BC24) release plan has been updated:
Define extension objects in same app as their base object

Business value
By allowing the segmentation of objects into base functionality and extended functionality, it becomes possible to define extensions to objects in the same app as the object itself. This provides an option to group related functionality in smaller contributions and makes it easier to later move these to a separate app as part of refactoring.

Feature details
With this new feature, it’s possible to define both the base object and extension objects in the same app. For instance, a table and a table extension can be defined within the same app.

In metadata, extension objects remain separate, as before, so each extension object still requires its own object ID in the used range. The key change is that they can now reside in the same extension/app as the base object. In the case of tables, table extensions that reside in the same app as the base table will be merged into that table in the database schema—resulting in no companion table extension.

This feature is applicable to all extensible object types; for example, page, table, report, enum, and permission set objects.

The capability is enabled by default when targeting runtime version 13.0.

https://learn.microsoft.com/en-us/dynamics365/release-plan/2024wave1/smb/dynamics365-business-central/define-extension-objects-same-app-as-their-base-object?wt.mc_id=DX-MVP-5004336

In Business Central, AL developers can extend the functionality of Business Central in several ways. One of them is through Extension Objects.
Table Extension Object: The table extension object allows you to add additional fields or to change some properties on a table provided by the Dynamics 365 Business Central service.

Page Extension Object: The page extension object extends a Dynamics 365 Business Central page object and adds or overrides the functionality.

Report extension object: With the report extension object, you can extend existing report objects, similar to how you extend tables and pages.

Permission Set Extension Object: The permission set extension object in Business Central adds permissions to an existing permission set defined in AL.

Enumextension object: Enums can be extended in order to add more values to the enumeration list in which case the Extensible property must be set to true.

But there are two limitations in BC23.5 and previous versions.
1. If you create an object in an extension/app, you cannot create its extension object.
For example, I created a new table “Lab Book”, and when I create its tableextension in the same extension/app, the following error occurs.

The extension object ‘Lab Book Ext’ cannot be declared. Another extension for target ‘Lab Book’ or the target itself is already declared in this module.AL AL0334

2. When creating an extension objects, only one extension object can be created for the same target in the same extension/app.
For example, I tried to create multiple tableextensions to extend the standard customer table, the following error occurs.

The extension object ‘CustomerExt2’ cannot be declared. Another extension for target ‘Customer’ or the target itself is already declared in this module.AL AL0334

This is standard behavior since extension v2 was released. In order to prevent management confusion, Microsoft introduced this method. But with this wave (BC24), this has changed.

In BC24.0:
Extensions can now exist in the same app as their target. (For table extensions in the same app as their target, the fields and keys will be moved to the base table to prevent SQL-joins at runtime)

Multiple extensions to the same target can exist in the same app.

In addition, the control mentioned below will not occur during Package, but errors will occur during installation.

The base object cannot reference members from extension objects.

error AL0118: The name ‘”Published Date”‘ does not exist in the current context.

The following control currently do not cause errors and can be packaged or installed. (Maybe it will be fixed in a future version)

Extension objects can reference members from other extension objects in the same app only if the other extension object has a lower object ID.

That’s all, but why is Microsoft doing this change? In Directions EMEA 2023, Microsoft introduced the new Business Foundation app and will gradually transfer the code in the base application to the Business Foundation app in the future. More details: Business Central is open source! from Natalie Karolak

And Microsoft released the following two new properties in BC23 (runtime version 12.0) to move tables between extensions/apps. As of now, only Microsoft standard objects are available.
MovedFrom Property: Specifies the origin extension ID when a table is moved to a new extension. If the source table exists in the database during the sync operation, the table will be moved to this extension along with all its data. Otherwise, a new table will be created in the database.
MovedTo Property: Specifies the destination extension Id when a table is moved to another extension.

In order to solve the performance problem of multiple table extensions, in the same version (BC23), Microsoft released the new Data model for table extensions. More details: Business Central 2023 wave 2 (BC23): New Data model for table extensions (Better performance when working with multiple extensions)

So including this new feature, I think these are the features that are preparing to reorganize the standard extensions/apps. The number of Microsoft first-party extensions is also growing……
PS: Dynamics 365 Business Central: Can we uninstall Microsoft (First-party) extensions and how to install them back?

Of course, as Microsoft mentioned, when we create large extensions/apps, this helps achieve better separation of concerns. Give it a try!!!😁

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL