web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

How to assign lot/serial number to Sales Order Line by program

(0) ShareShare
ReportReport
Posted on by

Hi Experts!

We're working on an Extension for 365BC.

We have some items with Tracking.

Could you please guide me how to assign lot/serial number to Sales Order Line by program?

And make sure it can be post to create a Posted Sales Shipments successfully.

Does 365 have some codeUnit help us to do that?

Thanks

Billy

Categories:
I have the same question (0)
  • Suggested answer
    I Gusti Made Ari Profile Picture
    3,608 on at

    you can check codeunit 99000830 "Create Reserv. Entry".

    Call  below 2 function in sequence , paramater value  is based on your sales line data :

    CreateReservEntry.CreateReservEntryFor

    CreateReservEntry.CreateEntry

  • Suggested answer
    Suresh Kulla Profile Picture
    50,269 Super User 2026 Season 1 on at

    Something like this

    TrackingSpecification@1240060000 : Record 336;
    ReservEntry@1240060001 : Record 337;
    ReserveSalesLine@1240060002 : Codeunit 99000832;
    LastEntryNo@1240060003 : Integer;
    CreateReservEntry@1240060004 : Codeunit 99000830;

    ReserveSalesLine.InitTrackingSpecification(SalesLine,TrackingSpecification);
    TrackingSpecification.VALIDATE("Serial No.","Serial No.");
    TrackingSpecification.VALIDATE("Quantity (Base)",Quantity);
    IF ItemTrackingMgt.IsOrderNetworkEntity(TrackingSpecification."Source Type",
    TrackingSpecification."Source Subtype") AND NOT ("Drop Shipment")
    THEN
    CurrentEntryStatus := CurrentEntryStatus::Surplus
    ELSE
    CurrentEntryStatus := CurrentEntryStatus::Prospect;


    CreateReservEntry.SetDates(
    TrackingSpecification."Warranty Date",TrackingSpecification."Expiration Date");
    CreateReservEntry.SetApplyFromEntryNo(
    TrackingSpecification."Appl.-from Item Entry");
    CreateReservEntry.CreateReservEntryFor(
    TrackingSpecification."Source Type",
    TrackingSpecification."Source Subtype",
    TrackingSpecification."Source ID",
    TrackingSpecification."Source Batch Name",
    TrackingSpecification."Source Prod. Order Line",
    TrackingSpecification."Source Ref. No.",
    TrackingSpecification."Qty. per Unit of Measure",
    TrackingSpecification."Quantity (Base)",
    TrackingSpecification."Quantity (Base)",
    TrackingSpecification."Serial No.",
    TrackingSpecification."Lot No.");
    CreateReservEntry.CreateEntry(TrackingSpecification."Item No.",
    TrackingSpecification."Variant Code",
    TrackingSpecification."Location Code",
    TrackingSpecification.Description,
    0D,
    "Shipment Date",0,CurrentEntryStatus);

    You need to convert this to AL.

  • Suggested answer
    Community Member Profile Picture
    on at

    Thank you, it is very useful and i modified some code to meet us (Billy and I ) requirements, below is our code:

    var
    ReservEntry: Record "Reservation Entry";
    CreateReserveEntry: Codeunit "Create Reserv. Entry";
    SalesLine: Record "Sales Line";
    sourceType: Integer;
    sourceSubType: Integer;

    trigger OnModify()
    begin
    sourceType := 37;
    sourceSubType := 1;


    SalesLine.SetRange("No.", "itemCode");
    SalesLine.SetRange("Document No.", "documentNumber");
    SalesLine.SetRange("Line No.", "lineNumber");
    if (SalesLine.FindSet()) then begin
    // Error(SalesLine."No.");

    CreateReserveEntry.CreateReservEntryFor(sourceType, sourceSubType, documentNumber, '', 0, lineNumber, SalesLine."Qty. per Unit of Measure"
    , quantity, quantityBase, serialNo, lotNo);
    //CreateReserveEntry.CreateReservEntry(SalesLine."No.", SalesLine."Variant Code", SalesLine."Location Code", SalesLine.Description, SalesLine."Requested Delivery Date", SalesLine."Planned Shipment Date");
    CreateReserveEntry.CreateEntry(itemCode, SalesLine."Variant Code", SalesLine."Location Code", SalesLine.Description, SalesLine."Planned Delivery Date"
    , SalesLine."Planned Shipment Date", 0, 2);
    //ReservEntry.Init();
    if (ReservEntry.FindLast()) then begin
    rec."No." := ReservEntry."Entry No.";
    ReservEntry."Expiration Date" := "Expiration Date";
    ReservEntry."Warranty Date" := "Warranty Date";
    ReservEntry.Modify()
    end;
    end;
    //ReserveSalesLine.CreateReservation(SalesLine,SalesLine.Description, SalesLine."Planned Delivery Date",rec.quantity, rec.quantityBase,rec.serialNo, rec.lotNo);

    end;
  • PHT80 Profile Picture
    40 on at

    Hi everyone, I need your help.
    I am working on an Extension for 365BC and I need create Item tracking line. I am using the code above, but when I go to the Item Tracking Lines window, the "Lot No." field is empty.
    What I can do?

    thanks in advance

  • Community Member Profile Picture
    on at

    Maybe you need provide some screen shots or code sample. Did you use web service to create lot&serial?

  • PHT80 Profile Picture
    40 on at

    Hi MIng0515,

    I am not using web service, I am importing from a text file.

    This is the code I am using:

    pastedimage1573571500756v1.png

    Thank you.

  • Community Member Profile Picture
    on at

    Where your lotNo field value come from? did you pass lotNo field value?

  • PHT80 Profile Picture
    40 on at

    I solved the problem. There were erroneous data in the "Reservation Entry" table. I cleaned this data and now it works OK.

    Thank you !!

  • Umar Farooq Raja Profile Picture
    15 on at

    Hi PHT80!!!

    I am having same problem,  I am using the code above, but when I go to the Item Tracking Lines window, the "Lot No." field is empty.

    Will you please share your findings with me , so I can resolve my problem.

    Thanks

  • KC Lai Profile Picture
    335 on at

    Hi PHT80,

    We are having similar request from client to assign serial number to SO line.

    wonder you have solution?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans