ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Item Tracking Lines: modification request (necessary to add new fields)

Open Bleika opened this issue 7 years ago • 1 comments

Adding extra fields to Item Tracking (lot or serial attributes) is a common request. However, the current design doesn't allow for that as an extension: data is introduced through Page 6510 and any extension data will be lost when the page is closed. There are 2 scenarios and 2 different reasons:

Insert new Item Tracking: Even though data is tossed around endlessly in different functions, it's not actually written into the database until temporary Tracking Specification records are converted into Reservation Entries during a call to CU99000830 (Create Reservation Entry). The problem is that the Reservation Entry is out of scope for the Page, and the Tracking Spec is out of scope for the Codeunit that creates the entries. Therefore, current design passes static variables as parameters to the codeunit, instead of the temporary records themself. (Maybe it was designed that way originally because fields are "handpicked" from 2 temp records and combined in 1 Reservation Entry). Data must be saved in the InsertReservEntry record before temp Tracking Spec is deleted, but there is no function nor event that allows to do so. Proposed solution:

  • New event in CU99000830: LOCAL [IntegrationEvent] OnCreateExtraFields(VAR NewReservEntry : Record "Reservation Entry";OldExtraTrackingSpec : Record "Tracking Specification"; NewExtraTrackingSpec : Record "Tracking Specification")

  • New function in CU99000830: [External] CreateExtraFields(OldExtraTrackingSpec : Record "Tracking Specification"; NewExtraTrackingSpec : Record "Tracking Specification")

  • The new function only needs one line of code (to trigger the new event): OnCreateExtraFields(InsertReservEntry,OldExtraTrackingSpec, NewExtraTrackingSpec);

  • Add a call to the new function, within RegisterChange in Page 6510 where the Event OnAfterCreateReservEntryFor is currently (as the existing event doesn't have access to InsertReservEntry, I doubt it is useful at all): CreateReservEntry.CreateExtraFields(OldTrackingSpecification,NewTrackingSpecification);

That way, subscribers can mimic the same functionality as CreateEntry, CreateReservEntryFor, etc.

Modify Item Tracking: Changes are not written to database unless the EntriesAreIdentical function in Page 6510 returns false. 2 Arrays are compared to evaluate whether a change has occurred. Obviously, if you only change the extra fields, change goes unnoticed. Therefore, there are 2 requests already (#160 & #279) to add a new Event to hook into this code. However, I don't think it wise to expose that particular event as is: if the standard check on [2] returns false and the extension check returns true, nothing will be written to the database, since the condition has been updated. Another possibility is that there are 2 extensions: one returns true and the other false (and you end up with the same problem). The logic should therefore be: if standard code hasn't detected changes, let any extension code do its own checking. Proposed solution:

  • Add a new event (as already requested): LOCAL [IntegrationEvent] OnBeforeExitEntriesAreIdentical(VAR Re1 : Record "Reservation Entry";VAR Re2 : Record "Reservation Entry";VAR IdenticalArray : ARRAY [2] OF Boolean)

  • Add the following code before the EXIT statement in EntriesAreIdentical: IF IdenticalArray[2] THEN OnBeforeExitEntriesAreIdentical(ReservEntry1,ReservEntry2,IdenticalArray);

That way, checks don't interfere with each other and no change goes undetected.

Bleika avatar Jan 15 '19 15:01 Bleika

Is there any update on this request? This keeps us from moving important functionality of several solutions to extensions.

IngoStender avatar Jul 12 '19 13:07 IngoStender