Why do you need this change?
We need to validate container assignments and remove items from source containers in InitWhseEntry in Codeunit 7301 "Whse. Jnl.-Register Line" before the warehouse entry record is initialized. Container checks use the journal line's "From Container ID" and "To Container ID", and negative-sign entries must trigger container removal before warehouse entry fields are populated.
The standard procedure assigns the entry number and immediately calls WhseEntry.Init(), leaving no gap for container operations that must precede field assignment.
No existing event fires between the entry number assignment and WhseEntry.Init(). OnCodeBeforeInitWhseEntryFromBinCode fires before InitWhseEntry is called without Sign, ZoneCode, or BinCode parameters. OnInitWhseEntryCopyFromWhseJnlLine fires at the end of the procedure after all fields are assigned.
Describe the request
Add an integration event OnInitWhseEntryOnBeforeInitWhseEntry in InitWhseEntry in Codeunit 7301 "Whse. Jnl.-Register Line" after the entry number is assigned and before the warehouse entry record is initialized.
begin
GlobalWhseEntryNo := WhseEntry.GetNextEntryNo();
OnInitWhseEntryOnBeforeInitWhseEntry(
WhseEntry, WhseJnlLine, ZoneCode, BinCode, Sign, GlobalWhseEntryNo); // <---- New Event
WhseEntry.Init();
WhseEntry."Entry No." := GlobalWhseEntryNo;
WhseEntry."Journal Template Name" := WhseJnlLine."Journal Template Name";
WhseEntry."Journal Batch Name" := WhseJnlLine."Journal Batch Name";
if WhseJnlLine."Entry Type" <> WhseJnlLine."Entry Type"::Movement then begin
if Sign >= 0 then
WhseEntry."Entry Type" := WhseEntry."Entry Type"::"Positive Adjmt."
else
WhseEntry."Entry Type" := WhseEntry."Entry Type"::"Negative Adjmt.";
end else
WhseEntry."Entry Type" := WhseJnlLine."Entry Type";
WhseEntry."Line No." := WhseJnlLine."Line No.";
[IntegrationEvent(false, false)]
local procedure OnInitWhseEntryOnBeforeInitWhseEntry(var WhseEntry: Record "Warehouse Entry"; var WhseJnlLine: Record "Warehouse Journal Line"; ZoneCode: Code[10]; BinCode: Code[20]; Sign: Integer; var GlobalWhseEntryNo: Integer)
begin
end;
Alternatives evaluated: OnCodeBeforeInitWhseEntryFromBinCode fires before InitWhseEntry is called without Sign, ZoneCode, or BinCode parameters. OnInitWhseEntryCopyFromWhseJnlLine fires at the end of the procedure after all warehouse entry fields have been assigned, too late for container operations that must precede field initialization.
Why do you need this change?
We need to validate container assignments and remove items from source containers in InitWhseEntry in Codeunit 7301 "Whse. Jnl.-Register Line" before the warehouse entry record is initialized. Container checks use the journal line's "From Container ID" and "To Container ID", and negative-sign entries must trigger container removal before warehouse entry fields are populated.
The standard procedure assigns the entry number and immediately calls WhseEntry.Init(), leaving no gap for container operations that must precede field assignment.
No existing event fires between the entry number assignment and WhseEntry.Init(). OnCodeBeforeInitWhseEntryFromBinCode fires before InitWhseEntry is called without Sign, ZoneCode, or BinCode parameters. OnInitWhseEntryCopyFromWhseJnlLine fires at the end of the procedure after all fields are assigned.
Describe the request
Add an integration event OnInitWhseEntryOnBeforeInitWhseEntry in InitWhseEntry in Codeunit 7301 "Whse. Jnl.-Register Line" after the entry number is assigned and before the warehouse entry record is initialized.
Alternatives evaluated: OnCodeBeforeInitWhseEntryFromBinCode fires before InitWhseEntry is called without Sign, ZoneCode, or BinCode parameters. OnInitWhseEntryCopyFromWhseJnlLine fires at the end of the procedure after all warehouse entry fields have been assigned, too late for container operations that must precede field initialization.