Replace NoSeriesManagement with the new BC Foundation No. Series app (1/2)

by Feb 18, 2024AL Language

Home 9 Development 9 AL Language 9 Replace NoSeriesManagement with the new BC Foundation No. Series app (1/2) ( Page 2 )

In BC 2024 wave 1, Microsoft will introduce a new Business Central Foundation Layer with the first app – redesigned No. Series. A few weeks back, Microsoft merged their changes into the BCApps repository (see the pull request here: Introducing new Business Foundation layer – No. Series by AndreasMoth · Pull Request #319 · microsoft/BCApps (github.com).

Since then, Microsoft has been working on uptaking the changes to the core base app. Let’s have a look at how it’s implemented in the base app. You can use the same approach in your apps to redesign your custom modules to use the BC foundation layer.

No. field OnValidate()

There is only a small change in the No. OnValidate trigger. Instead of calling TestManual(…) from the NoSeriesManagement codeunit, the new implementation calls the same procedure TestManual(…) from the new BC foundation layer app “No. Series” codeunit.

Old implementation

        field(3; "No."; Code[20])
        {
            Caption = 'No.';
            trigger OnValidate()
            begin
                if "No." <> xRec."No." then begin
                    GetSalesSetup();
                    NoSeriesMgt.TestManual(GetNoSeriesCode());
                    "No. Series" := '';
                end;
            end;
        }

New implementation

        field(3; "No."; Code[20])
        {
            Caption = 'No.';
            trigger OnValidate()
            begin
                if "No." <> xRec."No." then begin
                    GetSalesSetup();
                    NoSeries.TestManual(GetNoSeriesCode());
                    "No. Series" := '';
                end;
            end;
        }

InitInsert()

The changes in the InitInsert(…) procedure are larger. The changes are done in a non-breaking way, so it should be safe to use the old implementation for at least the next two major releases.

The new implementation calls the existing events OnBeforeInitSeries() and OnAfterInitSeries() from the NoSeriesManagement indirectly. If you want to follow the same principle for your apps (which is especially important if you are an ISV publisher and there may be external customizations to your ISV solution), use the new procedures RaiseObsoleteOnBeforeInitSeries(…) and RaiseObsoleteOnAfterInitSeries(…) from the NoSeriesManagement codeunit.

Apart from the events, the implementation is similar. Instead of using InitSeries(…), there is a different procedure called AreRelated(…).

Old implementation

            if "No." = '' then begin
                TestNoSeries();
                NoSeriesMgt.InitSeries(GetNoSeriesCode(), xRec."No. Series", "Posting Date", "No.", "No. Series");
                SalesHeader2.ReadIsolation(IsolationLevel::ReadUncommitted);
                SalesHeader2.SetLoadFields("No.");
                while SalesHeader2.Get("Document Type", "No.") do
                    "No." := NoSeriesMgt.GetNextNo("No. Series", "Posting Date", true);
            end;

New implementation

            if "No." = '' then begin
                TestNoSeries();
                NoSeriesCode := GetNoSeriesCode();
#if not CLEAN24
                NoSeriesMgt.RaiseObsoleteOnBeforeInitSeries(NoSeriesCode, xRec."No. Series", "Posting Date", "No.", "No. Series", IsHandled);
                if not IsHandled then begin
#endif
                    "No. Series" := NoSeriesCode;
                    if NoSeries.AreRelated("No. Series", xRec."No. Series") then
                        "No. Series" := xRec."No. Series";
                    "No." := NoSeries.GetNextNo("No. Series", "Posting Date");
                    SalesHeader2.ReadIsolation(IsolationLevel::ReadUncommitted);
                    SalesHeader2.SetLoadFields("No.");
                    while SalesHeader2.Get("Document Type", "No.") do
                        "No." := NoSeries.GetNextNo("No. Series", "Posting Date");
#if not CLEAN24
                    NoSeriesMgt.RaiseObsoleteOnAfterInitSeries("No. Series", NoSeriesCode, "Posting Date", "No.");
                end;
#endif

It’s important to note that the update has not been completed yet! There will be further changes required, for example, to procedures TestNoSeries() and TestNoSeriesDate().

The update for these procedures will be done in the upcoming weeks and I’ll create another blog post to summarize the rest of required changes.

Recent Articles from the category

7 git commands you should know

7 git commands you should know

For many years, developers in C/AL did not need to know anything about Git or other versioning tools. That has changed with Business Central, or more specifically with AL Language. Today, we will look at the most important (and basic) git commands any developer should...

read more
How to define the source for item reservations?

How to define the source for item reservations?

It's not uncommon to have a customer's request to limit from which source items could be reserved. For example, customers may not want to reserve items from return orders. How can we achieve this goal? It's really simple. All the magic is done in the procedure...

read more
NavigationAction for ErrorInfo data type

NavigationAction for ErrorInfo data type

One more article about ErrorInfo data type. Have you already read my previous posts about ErrorInfo and Collectible Errors? ErrorInfo data type & Collectible Errors | MSDyn365 Business Central - Ing. Tomáš Kapitán (kepty.cz) Collectible Errors?! | MSDyn365...

read more
Error actions for ErrorInfo data type

Error actions for ErrorInfo data type

It is already almost one and a half years since the ErrorInfo data type was introduced (we saw this data type for the first time in BC2021w2). If you do not know what it is and how to use this data type, check my previous posts: ErrorInfo data type & Collectible...

read more
Data types under the microscope: List

Data types under the microscope: List

The List data type in AL language represents an ordered collection of objects that can be accessed by their index. Unlike an Array data type, a List does not have a fixed size and does not need to have its dimension specified when it is declared. The List data type...

read more
Connect to Azure Function in BC 2022 wave 2 (v21)

Connect to Azure Function in BC 2022 wave 2 (v21)

The new version of the Microsoft Dynamics 365 Business Central brought a new system module "Azure Functions" that makes integration with Azure Functions much easier and straightforward. The typical scenario, why to use Azure Functions together with Business Central,...

read more

Sign Up for News

Certifications

Highest certification
Microsoft Data Management and
also in D365 Business Central

Microsoft Certified: Dynamics 365 Business Central Functional Consultant Associate

See other certifications here