Skip to main content
Business Central forum
Answered

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

editSubscribe (0) ShareShare
ReportReport
Posted on by 176

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 176 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 176 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 176 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 59,844 Super User 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.

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Sundar…

Industry experts answer burning questions directly from our amazing Community…

Enabling Copilot Case and Conversation…

Agents can easily recap an ongoing chat, transcribe a voice conversation…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 282,978 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans