Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

New aproach with "No. Series" to substitute an EventSubscriber of "NoSeriesManagement"?

(3) ShareShare
ReportReport
Posted on by 7
Hi,
 
I am learning BC and AL Code and I have a doubt relating the new No. Series approach instead of the use of NoSeriesManagement that is deprecated and will be removed in the future.
 
I have been trying a solution for something done using NoSeriesManagement with the new No. Series approach but I don't an easy way to have the same functionality than before with NoSeriesManagement.
 
I am looking for some advice / help. I think this can be helpful for everyone that is using EventSubscribers on the deprecated NoSeriesManagement codeunit.
 
IN THE PAST WITH NoSeriesManagement:
  • I have an EventSubscriber on NoSeriesManagement codeunit, in the event "OnBeforeDoGetNextNo".
  • This EventSubscriber do only a few things. Then the standard code on the procedure "DoGetNextNo" of NoSeriesManagement codeunit is executed.
NOW WITH No. Series, I would have to:
  • Create a new codeunit that implements "No. Series - Single" interface.
  • Extending Enum "No. Series Implementation" to include a new value that implements the interface "No. Series - Single" with the new created codeunit just above.
  • ¿Copy all the code of the codeunit 306 "No. Series - Stateless Impl." in the new codeunit created? I have got real doubts about this and I don't like at all this approach (I will explain later why)
  • Modify the function "GetNextNo" to add the extra code I need.
PROBLEMS WITH THIS NEW APPROACH:
  • Copy the codeunit 306 "No. Series - Stateless Impl." in the new codeunit created is a very bad idea because I would have to be aware of all the changes of "No. Series - Stateless Impl." changes in the future in order to apply all the changes to the codeunit I have created. Really bad idea and not a good approach of taking profit of the standard code.
  • The idea with NoSeriesManagement before was to be able to add a little code but be able as well to execute the standard code.
  • With the new approach, if you want a slight addition in one standard function, you have to create your own codeunit that implements "No. Series - Single" interface and to include all the code of all the functions to be implemented. This code in this codeunit is the code that is going to be executed instead of the standard code of the codeunit 306 "No. Series - Stateless Impl.".
  • When copying codeunit 306 "No. Series - Stateless Impl.", the system does not compile because in the function "EnsureLastNoUsedIsWithinValidRange", it is used the codeunit "No. Series - Errors Impl.", that is protected.
WHAT I WOULD LIKE WITH THE NEW APPROACH:
  • A way to add a little code to existing standard code but to have the standard code executed as well.
FINAL DOUBTS AND ASKING FOR HELP:
  • Is there something I am missing?
  • Is there another way to try to get working what before was an EventSubscriber on NoSeriesManagement codeunit, in the event "OnBeforeDoGetNextNo"?
As I have got little experience and I am in the learning process, I wonder if there is another approach to this problem that I can't see because of my very low experience.
 
Thank you very much for your time and your help.
  • Suggested answer
    YUN ZHU Profile Picture
    84,274 Super User 2025 Season 1 on at
    New aproach with "No. Series" to substitute an EventSubscriber of "NoSeriesManagement"?
    Hi, hope the following helps as well.
    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)
     
    Thanks.
    ZHU
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    17,377 Super User 2025 Season 1 on at
    New aproach with "No. Series" to substitute an EventSubscriber of "NoSeriesManagement"?
  • Gerardo Rentería García Profile Picture
    19,644 Most Valuable Professional on at
    New aproach with "No. Series" to substitute an EventSubscriber of "NoSeriesManagement"?
  • Suggested answer
    Sohail Ahmed Profile Picture
    3,285 on at
    New aproach with "No. Series" to substitute an EventSubscriber of "NoSeriesManagement"?
    Welcome to the Business Central Community and the world of AL programming. It's great to see you exploring Business Central development. The shift from NoSeriesManagement to the new No. Series approach is a significant change, and I understand your concerns.
     
    Microsoft has deprecated NoSeriesManagement to improve modularity and maintainability. Instead of using an EventSubscriber on OnBeforeDoGetNextNo, the new approach requires implementing the No. Series - Single interface and extending the No. Series Implementation enum.
     
    Copying the entire No. Series - Stateless Impl. codeunit is not ideal, as future updates could break your implementation. Instead, you should extend the No. Series Implementation enum and implement only the necessary logic in a custom codeunit.
     
    Previously, NoSeriesManagement allowed adding custom logic while still executing standard code. With the new approach, you need to override the standard behavior. One solution is to call the standard GetNextNo function within your implementation to ensure that your custom logic runs alongside the default behavior.
     
    The compilation error related to No. Series - Errors Impl. being protected suggests that Microsoft intends for developers to use predefined interfaces rather than directly modifying core logic. You may need alternative methods to handle error validation.
     
    A recommended approach is to create a new codeunit that implements No. Series - Single, extend the No. Series Implementation standard GetNextNo function to retain standard behavior.
     
    Let me know if you need further clarification. I'm here to help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans