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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Lot No does not work when it is generated by code in transfer lines

(0) ShareShare
ReportReport
Posted on by 39

I am creating transfer order by code and it works but i want to assign lot no also i wrote this code

procedure AssignLotNO(transLine: Record "Transfer Line")

    var
        EntryNo: Integer;

    begin

        if LastTRackingSPecs.FindLast() then
            EntryNo := LastTRackingSPecs."Entry No." + 1;


        GetItem(transLine."Item No.");

        TRackingSpecs.InitFromTransLine(transLine, transLine."Shipment Date", Direction::Outbound);
        TRackingSpecs.Validate("Quantity Handled (Base)", 0);
        TRackingSpecs.Validate("Quantity Invoiced (Base)", 0);
        AssignNewLotNo(TRackingSpecs);
        TRackingSpecs."Qty. Rounding Precision (Base)" := 1;
        TRackingSpecs.Validate("Quantity (Base)", transLine.Quantity);
        TRackingSpecs."Entry No." := EntryNo;
        TRackingSpecs.Insert();
        TRackingSpecs."Qty. per Unit of Measure" := 1;
        TempItemTrackLineInsert.TransferFields(TRackingSpecs);
        TempItemTrackLineInsert.Insert();
    end;

    local procedure AssignNewLotNo(var specs: Record "Tracking Specification")
    var
        IsHandled: Boolean;

    begin
        Item.TestField("Lot Nos.");
        specs.Validate("Lot No.", NoSeriesMgt.GetNextNo(Item."Lot Nos.", WorkDate(), true));
    end;

    local procedure GetItem(ItemNo: Code[20])
    var


    begin
        if Item."No." <> ItemNo then begin
            Item.Get(ItemNo);
            Item.TestField("Item Tracking Code");
            if ItemTrackingCode.Code <> Item."Item Tracking Code" then
                ItemTrackingCode.Get(Item."Item Tracking Code");
        end;
    end
 it assigns lot no in item tracking lines but when i try to post the transfer order it given me that "You must assign a lot number for item" even though when i open item tracking lines there is Lot No assigned 
I have the same question (0)
  • Suggested answer
    Andy Sather Profile Picture
    on at
    RE: Lot No does not work when it is generated by code in transfer lines

    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.

    www.yammer.com/dynamicsnavdev

    I will open this up to the community in case they have something to add.

  • Verified answer
    YUN ZHU Profile Picture
    94,369 Super User 2025 Season 2 on at
    RE: Lot No does not work when it is generated by code in transfer lines

    Hi, just add a document for customizing Item Tracking Line, I hope it can give you some hints.

    7144.ms_2D00_dynamics_2D00_nav_2D00_2013_2D00_item_2D00_tracking_2D00_wp_2D00_ap.pdf

    Thanks

    ZHU

  • Muaaz Deyab Profile Picture
    39 on at
    RE: Lot No does not work when it is generated by code in transfer lines

    Thanks for your Answer, I read the document but did not get anything out of it.

    I get the error when I try to post transfer order on CodeUnit 22 on the procedure CheckItemTracking on this line

                  if GlobalItemTrackingSetup."Lot No. Required" and (ItemJnlLine."Lot No." = '') then

                      Error(GetTextStringWithLineNo(LotNoRequiredErr, ItemJnlLine."Item No.", ItemJnlLine."Line No."));

    it does not link the tracking specification and reservation entry to Item journal lines but I can see the lines when i open Item tracking lines of the transfer line

  • Muaaz Deyab Profile Picture
    39 on at
    RE: Lot No does not work when it is generated by code in transfer lines

    yzhums  I Saw one your blogs https://yzhums.com/7943/ (this one) I tried doing the same on transfer order but it does not work.

    Is there any additional thing I have to add to make it work with transfer order?

    Thank you in Advance

  • Suggested answer
    Muaaz Deyab Profile Picture
    39 on at
    RE: Lot No does not work when it is generated by code in transfer lines

    I Solved this by creating two entries in Reservation entry one with negative quantity from location and the other entry with positive quantity to location

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,921

#2
YUN ZHU Profile Picture

YUN ZHU 2,012 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,999 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans