Codeunit 99000845 "Reservation Management": SetExternalDocumentResEntry with SourceRecRef
As was mentioned in #8370 it is currently not possible to fully use reservation management with extension tables.
- Subscribing to OnSetReservSource() does not allow calling local UpdateReservation()
- Calling SetExternalDocumentResEntry() instead looks fine at first sight, but processing then fails later on because the global variable SourceRecRef is not set.
One way to solve this could be an overload of SetExternalDocumentResEntry() that accepts a record reference as additional parameter:
procedure SetExternalDocumentResEntry(ReservEntry: Record "Reservation Entry"; NewSourceRecRef: RecordRef; EntryIsPositive: Boolean)
begin
ClearAll;
TempTrackingSpecification.DeleteAll();
SourceRecRef := NewSourceRecRef;
CalcReservEntry := ReservEntry;
UpdateReservation(EntryIsPositive);
end;
Note: Unfortunately, with the current design of that function (i.e. ClearAll), the code in the function body must be repeated, otherwise the SourceRecRef is not available when doing UpdateReservation().
Additionally: Would it be possible to rename the UpdReservation parameter to EntryIsPositive? The current naming seems wrong/misleading.
Sorry, as it turns out, this is not the correct approach as it does not solve all cases.
I've opened a new issue #15801 with a better approach and therefore am closing this one.