Why do you need this change?
We need to intercept the CreateItemJnlLineFromEntry call inside the ApplyWith = 0 branch of ReApply to supply additional quantity data when populating the item journal line from the entry.
The standard CreateItemJnlLineFromEntry receives only ItemLedgEntry and ItemLedgEntry."Remaining Quantity", with no mechanism to pass additional quantity fields. Items with alternate units of measure carry a "Remaining Quantity (Alt.)" field that must also be transferred to the item journal line for the downstream ApplyItemLedgEntry call to process correctly.
No event exists between the ItemLedgEntry."Applies-to Entry" := ApplyWith assignment and the CreateItemJnlLineFromEntry call in this branch. OnBeforeReApply fires at procedure entry before item tracking setup, entry switching, and the ApplyWith branch decision are resolved. OnReApplyOnBeforeStartApply is only reached inside the ApplyWith <> 0 branch and is never fired when ApplyWith = 0. OnReApplyOnBeforeUpdateLinkedValuationDate fires after EnsureValueEntryLoaded later in the same branch, after CreateItemJnlLineFromEntry and ApplyItemLedgEntry have already run, making it too late to affect the journal line creation.
Describe the request
Add an integration event OnReApplyOnBeforeCreateItemJnlLineFromEntryApplyWithZero in ReApply in Codeunit 22 "Item Jnl.-Post Line" after ItemLedgEntry."Applies-to Entry" := ApplyWith and before CreateItemJnlLineFromEntry in the ApplyWith = 0 branch.
end else begin // ApplyWith is 0
ItemLedgEntry."Applies-to Entry" := ApplyWith;
IsHandled := false;
OnReApplyOnBeforeCreateItemJnlLineFromEntryApplyWithZero(ItemLedgEntry, ItemJnlLine, IsHandled); // <---- New Event
if not IsHandled then
CreateItemJnlLineFromEntry(ItemLedgEntry, ItemLedgEntry."Remaining Quantity", ItemJnlLine);
ItemJnlLine."Applies-to Entry" := ItemLedgEntry."Applies-to Entry";
GlobalItemLedgEntry := ItemLedgEntry;
ApplyItemLedgEntry(ItemLedgEntry, OldItemLedgEntry, ValueEntry, false);
TouchItemEntryCost(ItemLedgEntry, false);
ItemLedgEntry.Modify();
Event Signature:
[IntegrationEvent(false, false)]
local procedure OnReApplyOnBeforeCreateItemJnlLineFromEntryApplyWithZero(var ItemLedgEntry: Record "Item Ledger Entry"; var ItemJnlLine: Record "Item Journal Line"; var IsHandled: Boolean)
begin
end;
Alternatives evaluated: OnBeforeReApply fires at procedure entry before item tracking setup and the ApplyWith branch decision, so no entry or journal line data is yet resolved at that point. OnReApplyOnBeforeStartApply is raised only inside the ApplyWith <> 0 branch and is never reached when ApplyWith = 0. OnReApplyOnBeforeUpdateLinkedValuationDate fires after EnsureValueEntryLoaded later in the ApplyWith = 0 branch, by which point CreateItemJnlLineFromEntry and ApplyItemLedgEntry have already completed, making it too late to modify the journal line creation. No event currently exists before CreateItemJnlLineFromEntry in the ApplyWith = 0 branch of ReApply.
Internal work item: AB#638499
Why do you need this change?
We need to intercept the
CreateItemJnlLineFromEntrycall inside theApplyWith = 0branch ofReApplyto supply additional quantity data when populating the item journal line from the entry.The standard
CreateItemJnlLineFromEntryreceives onlyItemLedgEntryandItemLedgEntry."Remaining Quantity", with no mechanism to pass additional quantity fields. Items with alternate units of measure carry a"Remaining Quantity (Alt.)"field that must also be transferred to the item journal line for the downstreamApplyItemLedgEntrycall to process correctly.No event exists between the
ItemLedgEntry."Applies-to Entry" := ApplyWithassignment and theCreateItemJnlLineFromEntrycall in this branch.OnBeforeReApplyfires at procedure entry before item tracking setup, entry switching, and theApplyWithbranch decision are resolved.OnReApplyOnBeforeStartApplyis only reached inside theApplyWith <> 0branch and is never fired whenApplyWith = 0.OnReApplyOnBeforeUpdateLinkedValuationDatefires afterEnsureValueEntryLoadedlater in the same branch, afterCreateItemJnlLineFromEntryandApplyItemLedgEntryhave already run, making it too late to affect the journal line creation.Describe the request
Add an integration event
OnReApplyOnBeforeCreateItemJnlLineFromEntryApplyWithZeroinReApplyin Codeunit 22 "Item Jnl.-Post Line" afterItemLedgEntry."Applies-to Entry" := ApplyWithand beforeCreateItemJnlLineFromEntryin theApplyWith = 0branch.Event Signature:
Alternatives evaluated: OnBeforeReApply fires at procedure entry before item tracking setup and the ApplyWith branch decision, so no entry or journal line data is yet resolved at that point. OnReApplyOnBeforeStartApply is raised only inside the ApplyWith <> 0 branch and is never reached when ApplyWith = 0. OnReApplyOnBeforeUpdateLinkedValuationDate fires after EnsureValueEntryLoaded later in the ApplyWith = 0 branch, by which point CreateItemJnlLineFromEntry and ApplyItemLedgEntry have already completed, making it too late to modify the journal line creation. No event currently exists before CreateItemJnlLineFromEntry in the ApplyWith = 0 branch of ReApply.
Internal work item: AB#638499