Skip to main content

Notifications

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

printout serial number from item tracking lines

Posted on by 151

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

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: printout serial number from item tracking lines

    Hi,

    you need check where you have written logic and why it’s printing twice may be you can debug

  • aryaps Profile Picture
    aryaps 151 on at
    RE: printout serial number from item tracking lines

    Nitin Verma 

    Now, is there any issue in this code. while printing if the number of line item is 4 it takes 8 records are coming. means same 4 lines are also coming. and it should take only one warranty date from each of the item (if warranty date exists)

     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.", "Warranty Date", "Expiration Date");
                    ItemLedEntries.SetRange("Document Type", ItemLedEntries."Document Type"::"Sales Shipment");
                    ItemLedEntries.SetRange("Document No.", "Sales Shipment Line"."Document No.");
                    ItemLedEntries.SetRange("Document Line No.", "Sales Shipment Line"."Line No.");
                    if ItemLedEntries.FindFirst() then
                        //repeat
                            if WarrantyDate <> 0D THEN
                            WarrantyDate := ItemLedEntries."Warranty Date";
                    // until ItemLedEntries.Next() = 0;

                End;
  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: printout serial number from item tracking lines

    Thanks for update.

  • aryaps Profile Picture
    aryaps 151 on at
    RE: printout serial number from item tracking lines

    Thanks You Nitin Verma : it is working as expected

  • Suggested answer
    Tech-Lucky Profile Picture
    Tech-Lucky 796 on at
    RE: printout serial number from item tracking lines

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

  • aryaps Profile Picture
    aryaps 151 on at
    RE: printout serial number from item tracking lines

    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
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: printout serial number from item tracking lines

    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
    aryaps 151 on at
    RE: printout serial number from item tracking lines

    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
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: printout serial number from item tracking lines

    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
    aryaps 151 on at
    RE: printout serial number from item tracking lines

    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

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans