codeunit 99000845 "Reservation Management" - New event OnAfterGetItemSetup
Why do you need this change?
We would like to be able to utilize the AutoTrack functionality dynamically when certain conditions are fulfilled without having to set up the item to run AutoTrack all the time. The new events recently added (#29421 and #29424) has allowed us to do this by temporarily changing the "Order Tracking Policy" of the item, and that works really well. We have however identified some scenarios where the event in Reservation Management is not triggered and in order to complete the design we need a more general event also, ensuring that we always have access to the global Item variable, regardless of how the flow has been initiated.
Describe the request
In codeunit 99000845 "Reservation Management" local procedure GetItemSetup(var ReservEntry: Record "Reservation Entry") we would like a new event OnAfterGetItemSetup, passing the variables ReservEntry and Item as var as shown below.
local procedure GetItemSetup(var ReservEntry: Record "Reservation Entry")
var
PlanningGetParameters: Codeunit "Planning-Get Parameters";
begin
if ReservEntry."Item No." <> Item."No." then begin
Item.Get(ReservEntry."Item No.");
if Item."Item Tracking Code" <> '' then
ItemTrackingCode.Get(Item."Item Tracking Code")
else
ItemTrackingCode.Init();
PlanningGetParameters.AtSKU(
SKU, ReservEntry."Item No.", ReservEntry."Variant Code", ReservEntry."Location Code");
//>>New Code Begin
OnAfterGetItemSetup(ReservEntry, Item);
//<<New Code End
end;
end;
//>>New Code Begin
[IntegrationEvent(false, false)]
local procedure OnAfterGetItemSetup(var ReservationEntry: Record "Reservation Entry"; var Item: Record Item)
begin
end;
//<<New Code End
Internal work item: AB#621147
✅ Analysis complete - approved for implementation
Implementation:
Add the OnAfterGetItemSetup event call at the end of the GetItemSetup procedure to provide access to the Item variable after it has been loaded, allowing dynamic modification of AutoTrack behavior.
Location in the GetItemSetup procedure (lines 1413-1425):
local procedure GetItemSetup(var ReservEntry: Record "Reservation Entry")
var
PlanningGetParameters: Codeunit "Planning-Get Parameters";
begin
if ReservEntry."Item No." <> Item."No." then begin
Item.Get(ReservEntry."Item No.");
if Item."Item Tracking Code" <> '' then
ItemTrackingCode.Get(Item."Item Tracking Code")
else
ItemTrackingCode.Init();
PlanningGetParameters.AtSKU(
SKU, ReservEntry."Item No.", ReservEntry."Variant Code", ReservEntry."Location Code");
OnAfterGetItemSetup(ReservEntry, Item);
end;
end;
Event Publisher (add at the end of the codeunit with other events):
[IntegrationEvent(false, false)]
local procedure OnAfterGetItemSetup(var ReservationEntry: Record "Reservation Entry"; var Item: Record Item)
begin
end;
File: ReservationManagement.Codeunit.al
📝 Note: The GetItemSetup procedure is called from multiple places in the codebase (UpdateReservation, CalcReservedQtyOnPick, DeleteReservEntries, IssueActionMessage, AutoTrack). If you need your event subscriber to fire only in specific scenarios, consider using Manual Event Subscription Binding.
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.
Build ID: 46888.