Dynamics 365 Business Central: New “No. Series” module (Codeunit ‘NoSeriesManagement’ is marked for removal. Reason: Please use the “No. Series” and “No. Series – Batch” codeunits instead)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to briefly talk about a code processing change from Business Central 2024 wave 1 (BC24), new “No. Series” module.
For each company that you set up, you need to assign unique identification codes to things such as general ledger accounts, customer and vendor accounts, invoices, and other documents. Numbering isn’t only important for identification. A well-designed numbering system also makes the company more manageable and easier to analyze, and can reduce data entry errors. More details: Create number series

In How to use the standard No. Series on custom data in Dynamics 365 Business Central (Automatic Number Series), we discussed that this can also be used in our customization. For example,

But starting from Business Central 2024 wave 1 (BC24), if you still use the same method, there will be the following warning.

Codeunit ‘NoSeriesManagement’ is marked for removal. Reason: Please use the “No. Series” and “No. Series – Batch” codeunits instead

And TestManual method and InitSeries method have similar warnings.

Method ‘TestManual’ is marked for removal. Reason: Please use method TestManual(NoSeriesCode: Code[20]) in codeunit “No. Series” instead.. Tag: 24.0.AL AL0432

Method ‘InitSeries’ is marked for removal. Reason: Please use AreRelated in the “No. Series” codeunit instead. Tag: 24.0.AL AL0432

In Codeunit NoSeriesManagement:

OBSOLETE
This element will become obsolete from version 24.0. Please use the “No. Series” and “No. Series – Batch” codeunits instead

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

The first module to move is the No. Series module.

Module Business Foundation: Contains an expansive set of open source modules that make it easier to build, maintain, and easily upgrade on-premises and online apps. These modules let you focus on the business logic, and the needs of your users or customers.

All objects in Symbol file: Version: W1 24.1 (Platform 24.0.19566.0 + Application 24.1.18927.19282)

More details: Welcome to BCApps: Microsoft Dynamics 365 Business Central Application

Let’s take a look at some key points in BC24 standard codes.
table 18 Customer:
NoSeries: Codeunit “No. Series”;

NoSeries.TestManual(SalesSetup.”Customer Nos.”);

 “No.” := NoSeries.GetNextNo(“No. Series”);

So we also need to update our code.

                if "No." < xRec."No." then
                    if not ZYBook.Get(Rec."No.") then begin
                        SalesSetup.Get();
                        NoSeries.TestManual(SalesSetup."Book Nos.");
                        "No. Series" := '';
                    end;
        if "No." = '' then begin
            SalesSetup.Get();
            SalesSetup.TestField("Book Nos.");
            "No. Series" := SalesSetup."Book Nos.";
            if NoSeries.AreRelated(SalesSetup."Book Nos.", xRec."No. Series") then
                "No. Series" := xRec."No. Series";
            "No." := NoSeries.GetNextNo("No. Series");
        end;

A simple test:

Great.

You can find more comparison information between old and new below:
Refactoring to use the new No. Series module: This document provides brief explanations and some examples that can help you refactor your code to use the new No. Series module. Each section offers examples of the old and new ways of using the No. Series implementation. “Old” refers to how we currently do that, and “New” refers to using the new No. Series module. For example, InitSeries:

PS:
1. As of now, the old way remains, but please update your code as soon as possible!
How long time from obsoleted to deprecated?

2. Here is an illustration of an example timeline for an optional feature.

3. My test code: Github
table 50200 “ZY Book”

table 50200 "ZY Book"
{
    DataClassification = CustomerContent;

    fields
    {
        field(1; "No."; Code[10])
        {
            Caption = 'No.';
            DataClassification = CustomerContent;

            trigger OnValidate()
            var
                ZYBook: Record "ZY Book";
            begin
                /*if "No." < xRec."No." then begin
                    SalesSetup.Get();
                    NoSeriesMgt.TestManual(SalesSetup."Book Nos.");
                    "No. Series" := '';
                end;*/
                if "No." < xRec."No." then
                    if not ZYBook.Get(Rec."No.") then begin
                        SalesSetup.Get();
                        NoSeries.TestManual(SalesSetup."Book Nos.");
                        "No. Series" := '';
                    end;
            end;
        }
        field(2; Title; Text[30])
        {
            Caption = 'Title';
            DataClassification = CustomerContent;
        }
        field(3; Author; Text[30])
        {
            Caption = 'Author';
            DataClassification = CustomerContent;
        }
        field(4; "Page Count"; Integer)
        {
            Caption = 'Page Count';
            DataClassification = CustomerContent;
        }
        field(5; "No. Series"; Code[20])
        {
            Caption = 'No. Series';
            Editable = false;
            TableRelation = "No. Series";
        }
    }

    keys
    {
        key(PK; "No.")
        {
            Clustered = true;
        }
    }

    trigger OnInsert()
    var
    begin
        /*if "No." = '' then begin
            SalesSetup.Get();
            SalesSetup.TestField("Book Nos.");
            NoSeriesMgt.InitSeries(SalesSetup."Book Nos.", xRec."No. Series", 0D, "No.", "No. Series");
        end;*/
        if "No." = '' then begin
            SalesSetup.Get();
            SalesSetup.TestField("Book Nos.");
            "No. Series" := SalesSetup."Book Nos.";
            if NoSeries.AreRelated(SalesSetup."Book Nos.", xRec."No. Series") then
                "No. Series" := xRec."No. Series";
            "No." := NoSeries.GetNextNo("No. Series");
        end;
    end;

    var
        SalesSetup: Record "Sales & Receivables Setup";
        //NoSeriesMgt: Codeunit NoSeriesManagement;
        NoSeries: Codeunit "No. Series";
}

page 50200 “ZY Book Card”

page 50200 "ZY Book Card"
{
    Caption = 'Book Card';
    PageType = Card;
    SourceTable = "ZY Book";
    UsageCategory = Administration;

    layout
    {
        area(Content)
        {
            group(General)
            {
                field("No."; Rec."No.")
                {
                    ApplicationArea = All;
                }
                field(Title; Rec.Title)
                {
                    ApplicationArea = All;
                }
            }
            group(Details)
            {
                field(Author; Rec.Author)
                {
                    ApplicationArea = All;
                }
                field("Page Count"; Rec."Page Count")
                {
                    ApplicationArea = All;
                }
            }
        }
    }
}

page 50201 “ZY Book List”

page 50201 "ZY Book List"
{
    Caption = 'Book List';
    PageType = List;
    SourceTable = "ZY Book";
    ModifyAllowed = false;
    CardPageId = "ZY Book Card";
    UsageCategory = Lists;
    ApplicationArea = All;

    layout
    {
        area(Content)
        {
            repeater(Group)
            {
                field("No."; Rec."No.")
                {
                    ApplicationArea = All;
                }
                field(Title; Rec.Title)
                {
                    ApplicationArea = All;
                }
                field(Author; Rec.Author)
                {
                    ApplicationArea = All;
                }
                field("Page Count"; Rec."Page Count")
                {
                    ApplicationArea = All;
                }

            }
        }
    }
}

tableextension 50200 SalesReceivablesSetupExt extends “Sales & Receivables Setup”

tableextension 50200 SalesReceivablesSetupExt extends "Sales & Receivables Setup"
{
    fields
    {
        field(50200; "Book Nos."; Code[20])
        {
            Caption = 'Book Nos.';
            TableRelation = "No. Series";
            DataClassification = CustomerContent;
        }
    }
}

pageextension 50200 SalesReceivablesSetupPageExt extends “Sales & Receivables Setup”

pageextension 50200 SalesReceivablesSetupPageExt extends "Sales & Receivables Setup"
{
    layout
    {
        addafter("Customer Nos.")
        {
            field("Book Nos."; Rec."Book Nos.")
            {
                Caption = 'Book Nos.';
                ApplicationArea = All;
            }
        }
    }
}

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL