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)

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

BC Open Source? How to start?

BC Open Source? How to start?

BC Open Source? How to start? One of the most exciting news introduced last month in Lyon during Directions EMEA 2023 was the changes to the open-source initiative. This means that you can now contribute to the source code of the Base app and the System app, which are...

read more
Validate a FlowField Field. Wait? What?

Validate a FlowField Field. Wait? What?

Validate a FlowField Field. Wait? What? There are not many things in the AL Language that surprised me. However, last week, I found one such thing - I reviewed customizations made by another partner and had to analyze the OOTB code of the Demand Forecast matrix. I run...

read more
Dynamics NAV 2013 & Expired Cronus License

Dynamics NAV 2013 & Expired Cronus License

We found an interesting problem - we were not able to run the development environment for Dynamics NAV 2013. Whenever we tried to run the development client, we got the following error message: "Your program license has expired" and the development client has closed...

read more
Indirect Dependencies and Access Modifiers

Indirect Dependencies and Access Modifiers

Last week, there was a discussion on Yammer on how to get values from the "Sent Email" record when all fields are marked as Internal. I was surprised that many people do not know what can/can't access modifiers (such as local, protected, or internal) be used for. I...

read more
Clean up your copied environments

Clean up your copied environments

One of the most important things every developer should handle is to clean up the environment when the environment (or a company) is copied. Especially if the environment is managed directly by a client and they can create new copies anytime. Similarly, for copied...

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