So I have working AL code that hits our test BC 365 v19 W1 environment. In terms of creating new items, along with posting positive adjustments to the item journal to allocate site on-hand availability for each newly-created item. A new requirement would involve item serialization. Wondering at what point in my AL code would I instantiate the auto-assigned serial number for the items as I'm creating them. Would this take place in the positive adjustment that I'm inserting into the item journal? Haven't found any AL code examples searching online so far...
UPDATE: Disregard, as I see now that the reservation entry for the serialized item takes place after the item journal entry commits. I can take it from here :)
Yes, I wanted to use the Configuration Package to load both non-serialized Items and serialized items. Obviously the configuration package works fine for non-serialized items but now realized that I cannot load serialized items using the package. It looks I must have a developer add code to get it to work for serialized items.
If by loading serialized items you mean using the Excel sheet templates for importing, then I think those templates are just for non-serialized items. More barebones without the specificity. The way that worked for me was utilizing a AL codeunit extension to make the required reservation entry. The sample above worked, if that's a steer in the right direction.
I am looking for a way to load Serialzied Items but I see there is no way without developing code to add Item Serial Counts, correct?
Hi!
No problem to use this community as well for development type of questions. It is just that Microsoft support does not answer these kind of questions. To make you aware of our yammer groups, we refer to them.
Thank you so much for sharing the outcome! This is very helpful for the community.
Thanks for the info! I wasn't aware of these two other resources, as I thought that this Dynamics 365 Community area was the best place. Will check them out.
Just for some closure, and if anyone else would be interested, below is the AL code that accomplishes what I was looking to implement. Hope it helps someone who might run across it in the future.
procedure InsertItemJournal(ItemNo: Text; SerialNo: Text; LocationCode: Text; Qty: Integer; UnitCost: Decimal; DateIn: Text; VendorDocNo: Text; OurDocNo: Text; Descr: Text; ShortDim1Code: Text; ShortDim2Code: Text) var ItemJnl: Record "Item Journal Line"; TempReservEntry: Record "Reservation Entry" temporary; Rec_ResEnt_Lu: Record "Reservation Entry"; CreateReservEntry: Codeunit "Create Reserv. Entry"; ReservStatus: Enum "Reservation Status"; LineNo: Integer; ValDateIn: Date; begin ItemJnl.Init(); if ItemJnl.FindLast() then LineNo := ItemJnl."Line No." 10000 else LineNo := 10000; ItemJnl."Line No." := LineNo; ItemJnl."Entry Type" := ItemJnl."Entry Type"::"Positive Adjmt."; ItemJnl.Validate("Item No.", ItemNo); ItemJnl.Validate("Document No.", VendorDocNo); if OurDocNo = '' then ItemJnl.Validate(Description, Descr) else ItemJnl.Validate(Description, OurDocNo); ItemJnl.Validate("Journal Batch Name", 'DEFAULT'); ItemJnl.Validate("Journal Template Name", 'ITEM'); ItemJnl.Validate(Quantity, Qty); ItemJnl.Validate("Location Code", LocationCode); ItemJnl.Validate("Unit Amount", UnitCost); Evaluate(ValDateIn, DateIn); ItemJnl.Validate("Posting Date", ValDateIn); ItemJnl.Validate("Shortcut Dimension 1 Code", ShortDim1Code); ItemJnl.Validate("Shortcut Dimension 2 Code", ShortDim2Code); ItemJnl.Insert(); Commit(); TempReservEntry.Init(); Rec_ResEnt_Lu.Reset(); if Rec_ResEnt_Lu.FindLast() then TempReservEntry."Entry No." := Rec_ResEnt_Lu."Entry No." 1 else TempReservEntry."Entry No." := 1; if SerialNo <> '' then begin TempReservEntry."Serial No." := SerialNo; TempReservEntry.Quantity := Qty; TempReservEntry."Expiration Date" := Today(); TempReservEntry.Insert(); Commit(); CreateReservEntry.SetDates(0D, TempReservEntry."Expiration Date"); CreateReservEntry.SetNewSerialLotNo(TempReservEntry."Serial No.", TempReservEntry."Lot No."); CreateReservEntry.CreateReservEntryFor(Database::"Item Journal Line", ItemJnl."Entry Type".AsInteger(), ItemJnl."Journal Template Name", ItemJnl."Journal Batch Name", 0, ItemJnl."Line No.", ItemJnl."Qty. per Unit of Measure", TempReservEntry.Quantity, TempReservEntry.Quantity * ItemJnl."Qty. per Unit of Measure", TempReservEntry); CreateReservEntry.CreateEntry(ItemJnl."Item No.", ItemJnl."Variant Code", ItemJnl."Location Code", '', 0D, 0D, 0, ReservStatus::Surplus); end; end;
Hello,
We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.
dynamicsuser.net/.../developers
I will open this up to the community in case they have something to add.
Thanks.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156