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.
Categories: