So I am attempting to implement similar methodology to what's described here --> https://chrisdsilvablog.wordpress.com/2018/11/09/bar-code-integration-with-business-central/. In my case the user provides a Serial No. value into the item transfer order line, which is then backtraced so that the Item No. is then replaced into that field. And I am also needing to take an extra step, of adding the Serial No. item tracking details for the item transfer order line.
I ran across this helpful blog post --> which provides an example of creating those reservation entries. I will paste my AL code below and was wondering if any insight could be offered. When I am attempting to paste in a Serial No. into the transfer line's Item No. field, the translation doesn't occur. I just run into an error stating the transfer line for Line No. = 0 doesn't exist. I did place a Message() line right after the cross-reference lookup completes and can see the Item No. does pop up. But for some reason it's not pushing back into that field. Perhaps I should be just creating an extension of the form and not the table? I'm using BC365 v19 W1 on-prem.
tableextension 50103 "DchApi_TransferTableExt" extends "Transfer Line" { fields { modify("Item No.") { trigger OnBeforeValidate() var Rec_ILE: Record "Item Ledger Entry"; Rec_ResEnt: Record "Reservation Entry" temporary; Rec_ResEnt_Lu: Record "Reservation Entry"; CreateReservEntry: Codeunit "Create Reserv. Entry"; ItemTrackingMgt: Codeunit "Item Tracking Management"; ReservStatus: Enum "Reservation Status"; CurrentSourceRowID: Text[250]; SecondSourceRowID: Text[250]; SerialNo: Code[20]; begin SerialNo := Rec."Item No."; Rec_ILE.Reset(); Rec_ILE.SetRange("Entry Type", Rec_ILE."Entry Type"::Purchase); Rec_ILE.SetRange("Item Tracking", Rec_ILE."Item Tracking"::"Serial No."); Rec_ILE.SetFilter("Serial No.", '%1', Rec."Item No."); if Rec_ILE.FindFirst() then begin Message('The Item No. value is ' Rec_ILE."Item No."); // Replace the Item No. field with the true Item No. value for the item transfer line. Validate(Rec."Item No.", Rec_ILE."Item No."); // Add to the Quantity field value for the item transfer line. Validate(Rec.Quantity, 1); // Create a tracking specification entry for the item transfer line for the Serial No. value. Rec_ResEnt.Init(); Rec_ResEnt_Lu.Reset(); if Rec_ResEnt_Lu.FindLast() then Rec_ResEnt."Entry No." := Rec_ResEnt_Lu."Entry No." 1 else Rec_ResEnt."Entry No." := 1; Rec_ResEnt."Expiration Date" := Today(); Rec_ResEnt.Quantity := 1; Rec_ResEnt."Serial No." := SerialNo; Rec_ResEnt.Insert(); CreateReservEntry.SetDates(0D, Rec_ResEnt."Expiration Date"); CreateReservEntry.CreateReservEntryFor(Database::"Transfer Line", 0, Rec."Document No.", '', Rec."Derived From Line No.", Rec."Line No.", Rec."Qty. per Unit of Measure", Rec_ResEnt.Quantity, Rec."Qty. per Unit of Measure" * Rec_ResEnt.Quantity, Rec_ResEnt); CreateReservEntry.CreateEntry(Rec."Item No.", Rec."Variant Code", Rec."Transfer-from Code", Rec.Description, Rec."Receipt Date", 0D, 0, ReservStatus::Surplus); CurrentSourceRowID := ItemTrackingMgt.ComposeRowID(5741, 0, Rec."Document No.", '', 0, Rec."Line No."); SecondSourceRowID := ItemTrackingMgt.ComposeRowID(5741, 1, Rec."Document No.", '', 0, Rec."Line No."); ItemTrackingMgt.SynchronizeItemTracking(CurrentSourceRowID, SecondSourceRowID, ''); end; end; } } }