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 :
Small and medium business | Business Central, N...
Answered

printout serial number from item tracking lines

(0) ShareShare
ReportReport
Posted on by 155

Hello all,

in Sales , Purchases we have serial number and warranty dates are there in item tracking lines. but it is not available in Sales lines. how we can bring these 2 details in the report extension.

eg, how can we bring/modify those 2 fields into Posted Purchase receipt (Grn) and posted sales shipment.

reportextension 60002 "Sales - Shipment EMP Ext" extends "Sales - Shipment EMP"
{
    RDLCLayout = './ReportLayouts/SalesShipmentDeliveryNotes.rdl';
    dataset
    {
        // Add changes to dataitems and columns here
        add("Sales Shipment Header")
        {
            column(ShowUnitPrice; ShowUnitPrice)
            {
            }
            column(PostingDate_SalesShipmentHeader; "Posting Date")
            {
            }
            column(DocumentDate_SalesShipmentHeader; "Document Date")
            {
            }
        }


    }

    requestpage
    {
        // Add changes to the requestpage here
        /* layout
         {
             modify(ShowValue)
             {
                 Visible = false;
             }

         }*/
    }
    trigger OnPreReport()
    var
        WarehouseEmployee: Record "Warehouse Employee";
    begin
        WarehouseEmployee.Init();
        WarehouseEmployee.SetRange("User ID", UserId);
        If WarehouseEmployee.FindFirst() then
            ShowUnitPrice := false
        else
            ShowUnitPrice := true;
    end;

    var
        ShowUnitPrice: Boolean;
}

Thankyou all

I have the same question (0)
  • Suggested answer
    NAV_with_Narang Profile Picture
    2,374 Moderator on at

    The serial number/lot number although attached to your Sales Line, is maintained in a different table.

    If you are talking about bringing the data from Posted Purchase Receipt, then you need to look at Item ledger entries for that. You can link Purchase Receipt no, with the document no of ILE and ILE Document Type = Purchase

  • aryaps Profile Picture
    155 on at

    could you pls help me with modifying the above code?

  • Suggested answer
    Tech-Lucky Profile Picture
    1,288 Moderator on at

    Hi,

    if you need to print the Serial no / lot no on the reports made from posted tables like you have mentioned then you can retrieve the data from Item ledger entries with filter of document no. & line no .

    You can write this code :

    Var

    ItemLedEntries : Record "Item Ledger Entries";

    SerialNo : Code [20];

    ItemLedEntries .Reset();

    ItemLedEntries .strange("Document No,",SalesShipmentLine."Document No.");

    ItemLedEntries .strange("Document Line No.",SalesShipmentLine."Line No." );

    IF ItemLedEntries.Findfirst() Then

    SerialNo := ItemLedEntries."Serial No.";

    this is just a example how you can retrieve the data on the above report

    now if you want to flow these fields directly to the Posted tables without using the Item Ledger Entry then you have 2 approaches

    1.) Create custom fields on the Sales Line Extension table & the other posted tables like the sales inv line & Sales Shipment Line Extension tables with the same ID, when the Serial no is assigned to the sales line you can find the events and do the code to flow it to your custom fields then it will normally flow to posted tables after posting the documents Same applies to the purchase module as well.

    2.) Create the Flow Fields in the Posted Line Tables from the Item Ledger Entries with Document No. & Document Line No. Linking --this is not recommended this is just a possibility I am suggesting.

    Please verify my answer if it helps you

  • aryaps Profile Picture
    155 on at

    What is the error in the below code for fetching serial number into the Posted purchase receipt

    /// <summary>
    /// Unknown Posted Purchase Rcpt (JobNo) (ID 60016) extends Record Good Receipt Note.
    /// </summary>
    reportextension 60016 "Posted Purchase Rcpt (JobNo)" extends "Good Receipt Note"
    {

        //RDLCLayout = './ReportLayouts/PostedPurRcptGRN.rdl';
        dataset
        {
            add("Purch. Rcpt. Header")
            {
                column(RefDocNo; RefDocNo)
                {
                }
                column(RefJobNo; RefJobNo)
                {
                }
            }
            modify("Purch. Rcpt. Header")
            {
                trigger OnAfterAfterGetRecord()
                var
                    PostedPurchRecptLineRec: REcord "Purch. Rcpt. Line";
                begin
                    Clear(RefJobNo);
                    Clear(RefDocNo);
                    PostedPurchRecptLineRec.Reset();
                    PostedPurchRecptLineRec.SetRange("Document No.", "Purch. Rcpt. Header"."No.");
                    PostedPurchRecptLineRec.SetFilter("Ref. Document No.", '<>%1', '');
                    If PostedPurchRecptLineRec.FindFirst() then
                        RefDocNo := PostedPurchRecptLineRec."Ref. Document No.";
                    PostedPurchRecptLineRec.Reset();
                    PostedPurchRecptLineRec.SetRange("Document No.", "Purch. Rcpt. Header"."No.");
                    PostedPurchRecptLineRec.SetFilter("Ref. Job No.", '<>%1', '');
                    If PostedPurchRecptLineRec.FindFirst() then
                        RefJobNo := PostedPurchRecptLineRec."Ref. Job No.";
                end;
            }


            // Add changes to dataitems and columns here
            add("Purch. Rcpt. Line")
            {
                column(Ref__Job_No_; "Ref. Job No.")
                {

                }
                column(Job_No_; "Job No.")
                {

                }

                //
            }
            modify("Purch. Rcpt. Line")
            {
                trigger OnAfterAfterGetRecord()
                var
                    PostedPurchRecptLineRec: REcord "Purch. Rcpt. Line";
                    ItemLedEntries: Record "Item Ledger Entry";
                begin
                    Clear(SerialNo);
                    ItemLedEntries.Reset();
                    ItemLedEntries.SetRange("Document No.", PostedPurchRecptLineRec."Document No.");
                    ItemLedEntries.SetRange("Document Line No.", PostedPurchRecptLineRec."Line No.");
                    if
                    ItemLedEntries.FindFirst() then
                        SerialNo := ItemLedEntries."Serial No.";

                End;


            }


        }
        rendering
        {
            layout(GRNExtension)
            {
                Type = RDLC;
                LayoutFile = './ReportLayoutExtension/GoodRecptNote50102.rdl';
            }
        }
        var
            RefDocNo: Code[20];
            RefJobNo: Code[20];
            SerialNo: Code[20];
    }
  • aryaps Profile Picture
    155 on at

    here pls correct me here what is the issue.- ON posted Sales Shipment Print 

    i want to get only one warranty date & Expiration date for each item (if qty is 50 then also one want to pick 1 date) - if warranty date exits for that items

    modify("Sales Shipment Line")
            {
                trigger OnAfterAfterGetRecord()
                var

                    ItemLedEntries: Record "Item Ledger Entry";
                begin

                    Clear(WarrantyDate);
                    ItemLedEntries.Reset();
                    ItemLedEntries.SetCurrentKey("Document Type", "Document No.", "Document Line No.");
                    ItemLedEntries.SetLoadFields("Document Type", "Document No.", "Document Line No.", "Serial No.", "Warranty Date", "Expiration Date");
                    ItemLedEntries.SetRange("Document Type", ItemLedEntries."Document Type"::"Purchase Receipt");
                    ItemLedEntries.SetRange("Document No.", "Sales Shipment Line"."Document No.");
                    ItemLedEntries.SetRange("Document Line No.", "Sales Shipment Line"."Line No.");
                    if ItemLedEntries.FindSet() then
                        repeat
                            if WarrantyDate = 0D THEN
                                WarrantyDate := ItemLedEntries."Warranty Date";
                        until ItemLedEntries.Next() = 0;

                End;
    Thankyou
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    If I understood it correctly the requirement then see my code

    modify("Sales Shipment Line")
            {
                trigger OnAfterAfterGetRecord()
                var
    
                    ItemLedEntries: Record "Item Ledger Entry";
                begin
    
                    Clear(WarrantyDate);
                    ItemLedEntries.Reset();
                    ItemLedEntries.SetCurrentKey("Document Type", "Document No.", "Document Line No.");
                    ItemLedEntries.SetLoadFields("Document Type", "Document No.", "Document Line No.", "Serial No.", "Warranty Date", "Expiration Date");
                    ItemLedEntries.SetRange("Document Type", ItemLedEntries."Document Type"::"Purchase Receipt");
                    ItemLedEntries.SetRange("Document No.", "Sales Shipment Line"."Document No.");
                    ItemLedEntries.SetRange("Document Line No.", "Sales Shipment Line"."Line No.");
                    ItemLedEntries.setfilter("Warranty Date",'<>%1',0D);
                    if ItemLedEntries.findlast then
                        WarrantyDate := ItemLedEntries."Warranty Date";
                End;

  • aryaps Profile Picture
    155 on at

    Hello Nitin Verma 

    thanks for the reply, but still the warranty date is not getting from the ledger entries. if we have 10qty with warranty date we have to pick only one warranty date for each item (if warranty date exits)

    modify("Sales Shipment Line")
            {
                trigger OnAfterAfterGetRecord()
                var
    
                    ItemLedEntries: Record "Item Ledger Entry";
                begin
    
                    Clear(WarrantyDate);
                    ItemLedEntries.Reset();
                    ItemLedEntries.SetCurrentKey("Document Type", "Document No.", "Document Line No.");
                    ItemLedEntries.SetLoadFields("Document Type", "Document No.", "Document Line No.", "Serial No.", "Warranty Date", "Expiration Date");
                    ItemLedEntries.SetRange("Document Type", ItemLedEntries."Document Type"::"Purchase Receipt");
                    ItemLedEntries.SetRange("Document No.", "Sales Shipment Line"."Document No.");
                    ItemLedEntries.SetRange("Document Line No.", "Sales Shipment Line"."Line No.");
                    // if ItemLedEntries.FindSet() then
                    //     repeat
                    //         if WarrantyDate = 0D THEN
                    //             WarrantyDate := ItemLedEntries."Warranty Date";
                    //     until ItemLedEntries.Next() = 0;
                    ItemLedEntries.setfilter("Warranty Date", '<>%1', 0D);
                    if ItemLedEntries.findlast then
                        WarrantyDate := ItemLedEntries."Warranty Date";
                End;
    
    
    
    
            }
    
    
        var
            
            WarrantyDate: Date;
    }

    w1.jpg

    w2.jpg

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Can you try this? If it not works still, you need to debug and check your filters again. Also you need to declared your warranty date as a global varlable in that report.

    modify("Sales Shipment Line")
            {
                trigger OnAfterAfterGetRecord()
                var
    
                    ItemLedEntries: Record "Item Ledger Entry";
                begin
    
                    Clear(WarrantyDate);
                    ItemLedEntries.Reset();
                    ItemLedEntries.SetCurrentKey("Document Type", "Document No.", "Document Line No.");
                    ItemLedEntries.SetRange("Document Type", ItemLedEntries."Document Type"::"Purchase Receipt");
                    ItemLedEntries.SetRange("Document No.", "Sales Shipment Line"."Document No.");
                    ItemLedEntries.SetRange("Document Line No.", "Sales Shipment Line"."Line No.");
                    ItemLedEntries.SetLoadFields("Document Type", "Document No.", "Document Line No.", "Serial No.", "Warranty Date", "Expiration Date");
                    // if ItemLedEntries.FindSet() then
                    //     repeat
                    //         if WarrantyDate = 0D THEN
                    //             WarrantyDate := ItemLedEntries."Warranty Date";
                    //     until ItemLedEntries.Next() = 0;
                    ItemLedEntries.setfilter("Warranty Date", '<>%1', 0D);
                    if ItemLedEntries.findlast then
                        WarrantyDate := ItemLedEntries."Warranty Date";
                End;
    
    
    
    
            }
    
    
        var
            
            WarrantyDate: Date;
    }

  • aryaps Profile Picture
    155 on at

    Thanks for reply Nitin Verma 

    Right now am getting the warranty date, but the issue is each item has different warranty date, then also it is taking same warranty date for all items. if the item has no warranty date then also its taking one value

    w3.jpg

    w4.jpg

  • Suggested answer
    Tech-Lucky Profile Picture
    1,288 Moderator on at

    Use Last() function in your report layout for the warranty variable like: in the expression place holder =Last(WarrantyDate)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,034 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,199 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,080

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans