-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EVENT REQUEST] Codeunit 925 (Assembly Header-Reserve) #28006
Comments
@MarkusW-BSG IsHandled events are making code difficult to maintain and are leading to fragile solutions. Issue is that we are turning off large sections of the code. These solutions can easily break your implementation if we change the code that is currently called, you would need to react and update the code. We are also seeing these problems with partner code: multiple extensions can clash trying to handle the same event, one extension is shutting off the code from another extension that is expecting that the events from the code will be called. Can you please restructure the code to use different events instead of the handled event? We could add regular events in the different places to enable you to run more code, or to turn-off/skip less. |
@nikolakukrika please give me a hint how I can extend the codeunit / the functions without any event. If you create any other events that suits better for you and it is still possible for me to handle reservations differently / in an extended way this is completely okay. As described in "additional context" we handle two quantities / units, not just one. Making it necessary to handle reservations differently (in an extended way) |
@MarkusW-BSG I did not say without the event. Could you change the code to allow handling of the two quantities in the existing code instead of turning off the methods above? These could be other events that are in the places where we have issues of handling multiple quantities. It is going to be a much better solution as we will see the intent when adding new code. Handled "pattern" has caused a lot of issues to the partner extensions, we are receiving complaints about coding this way. It is quick but it is also dirty, the price will be paid down the line in maintenance and it is higher. We could also discuss this with the feature team, if they find this useful, you could change the base app code and introduce it as a proper extensibility/solution. If you are interested, I could ask to get you access to the GitHub and modify base app code. We could also do a proper interface, thus you can replace the entire codeunit with your own interface implementation. |
@nikolakukrika I originally copied it with CU 2 of BC24 and upgraded to CU 8 two weeks ago, finding Standard codeunit 22 changed in quite some very important places. Which I now need to re-implement into my version of 22. Which is no nice solution. :-) Having an interface would be awesome. I often heard about you guys working on implementing them in different places. I still did not get how it works (as up to now I did not use it) but I think this is the perfect solution for everyone who needs to completely redesign patterns of Business Central (or who has two companies in his database using diffent accountings). For all other code changes the events are still perfect (and you are extremely fast with implementing new ones! Thanks for that!). Btw: I implemented all my changes in Codeunit 90 with the existing non-invasive events! I will recall both Event Requests and redesign them for a better and more stable coding. Greetings |
@nikolakukrika Greetings |
@MarkusW-BSG thanks a lot. This is a great example how we can move away from the Handled events. |
Describe the request
Request 1 VerifyQuantity
procedure VerifyQuantity(var NewAssemblyHeader: Record "Assembly Header"; var OldAssemblyHeader: Record "Assembly Header")
has no appropriate event to customize the code
Please add two events
First Event
OnBeforeDeleteReservEntries(var NewAssemblyHeader: Record "Assembly Header"; OldAssemblyHeader: Record "Assembly Header")
Call
OnBeforeDeleteReservEntries(...)
ReservationManagement.DeleteReservEntries(false, NewAssemblyHeader."Remaining Quantity (Base)");
Usage:
Pass parameters to function DeleteReservationEntries (i.e. our Remaining Sec. Quantity) indirectly
Second Event:
OnBeforeAutoTrack(var NewAssemblyHeader: Record "Assembly Header")
Call
OnBeforeAutoTrack(...)
ReservationManagement.AutoTrack(NewAssemblyHeader."Remaining Quantity (Base)");
Usage:
Pass parameters to function AutoTrack(i.e. our Remaining Sec. Quantity) indirectly
Request 2 - TransferAsmHeaderToItemJnlLine
procedure TransferAsmHeaderToItemJnlLine(var AssemblyHeader: Record "Assembly Header"; var ItemJournalLine: Record "Item Journal Line"; TransferQty: Decimal; CheckApplToItemEntry: Boolean): Decimal
is completely free of events
New Event
TransferAsmHeaderToItemJnlLineOnBeforeTransferReservEntry(var AssemblyHeader: Record "Assembly Header"; var ItemJournalLine: Record "Item Journal Line"; var OldReservationEntry: Record "Reservation Entry")
Call
TransferAsmHeaderToItemJnlLineOnBeforeTransferReservEntry(...)
TransferQty := CreateReservEntry.TransferReservEntry(
Database::"Item Journal Line",
ItemJournalLine."Entry Type".AsInteger(), ItemJournalLine."Journal Template Name",
ItemJournalLine."Journal Batch Name", 0, ItemJournalLine."Line No.",
ItemJournalLine."Qty. per Unit of Measure", OldReservationEntry, TransferQty);
Usage:
Pass parameters indirectly to function
Additional context
In Steel Industry, one quantity is not enough for any process. Therefore our current Business Central is customized for using a second quantity. Every item has furthermore two inventories instead of one. An inventory measured by the base UOM (the standard) and a second one measure by its second UOM.
Example:
A customer orders approx. 2 tons of steel sheets, /.100 pieces.
Quantity: 2000
UOM: KG
Sec. Quantity: 100
Sec. UOM: PCE
Internal work item: AB#563877
The text was updated successfully, but these errors were encountered: