If you've been working with Microsoft Dynamics 365 Business Central for a while, you're probably familiar with the classic NoSeriesManagement codeunit. It’s been the go-to for generating and managing number series across modules like sales, purchasing, and finance.
But times are changing.
Microsoft is officially retiring NoSeriesManagement,
and introducing a modern, modular design pattern that aligns with the
new Business Foundation layer. This shift is part of a broader effort to
decouple core ERP functionality from the monolithic Base App and make Business
Central more extensible, testable, and future-proof.
Let’s break down what’s changing and how you can adapt.
What’s Going Away?
The legacy codeunit:
Codeunit 396 "NoSeriesManagement"
is being deprecated. It relied heavily on implicit logic and
constructs like xRec, which made it harder to maintain and test.
Example of old usage:
NoSeriesManagement.InitSeries(SalesSetup."Customer
Nos.", xRec."No. Series", 0D, "No.", "No.
Series");
This pattern is no longer recommended and will eventually be
unsupported.
What’s Replacing It?
Microsoft now recommends using two new codeunits:
1. Codeunit 310 "No. Series"
For single number generation.
2. Codeunit 311 "No. Series – Batch"
For bulk number generation.
These are part of the Business Foundation App and
follow a clean, modular design.
New Design Pattern: Cleaner and Explicit
Here’s how you generate a number using the new pattern:
procedure AssignNoSeries()
var
NoSeries: Codeunit "No.
Series";
SalesSetup: Record "Sales &
Receivables Setup";
begin
SalesSetup.Get();
SalesSetup.TestField("Customer
Nos");
"No. Series" :=
SalesSetup."Customer Nos.";
"No." :=
NoSeries.GetNextNo("No. Series");
end;
Key Differences:
Feature |
Old
Pattern |
New
Pattern |
Codeunit |
NoSeriesManagement |
No. Series / No.
Series – Batch |
Dependency |
Implicit (xRec) |
Explicit
field assignment |
Extensibility |
Limited |
Modular and
testable |
Compatibility |
Legacy |
Future-proof
(Business Foundation) |
Why This Matters
- Modularity:
The new pattern is part of Microsoft’s push toward modular architecture.
- Testability:
Easier to write unit tests and validate logic.
- Clarity:
No more hidden dependencies like xRec.
- Performance:
Batch codeunit improves performance for bulk operations.
What You Should Do
- Refactor
your AL code to use No. Series instead of NoSeriesManagement.
- Avoid
using xRec for number series logic.
- Explore
the Business Foundation App via AL Explorer to understand other
modular changes.
- Prepare
for future updates - this is just the beginning of Microsoft’s
modularization journey.
Final Thoughts
The retirement of NoSeriesManagement marks a significant
shift in how developers interact with Business Central’s core features. While
change can be daunting, this new design pattern offers a cleaner, more
maintainable way to manage number series - and sets the stage for a more modern
ERP experience.
If you're still using the old pattern, now’s the time to refactor. Your future self (and your codebase) will thank you.
No comments:
Post a Comment