Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

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

Posted on by 184

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 
  • Suggested answer
    Muaaz Deyab Profile Picture
    Muaaz Deyab 184 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

  • Muaaz Deyab Profile Picture
    Muaaz Deyab 184 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

  • Muaaz Deyab Profile Picture
    Muaaz Deyab 184 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

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 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

  • Suggested answer
    Andy Sather Profile Picture
    Andy Sather 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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans