Skip to main content
Microsoft Dynamics NAV forum
Suggested answer

AL code:- Update value in a last row of item ledger entry page based on Item page data

editSubscribe (0) ShareShare
Posted on by UG Leader
In a below code I created one custome page Bin Data and my source table is "Item Ledger Entry". I am getting right value in a bin data QtyAvail field.  If I have ten rows in bin data with same item no (Item1234) then it's updating  QtyAvail in each row of list. However, I wanted to update value in last row each time, not in all rows. Could you help me where I am doing wrong.
page 50118 BinDataPage
    AdditionalSearchTerms = 'inventory transactions';
    ApplicationArea = Basic, Suite;
    Caption = 'Bin Data';
    DataCaptionExpression = GetCaption;
    DataCaptionFields = "Item No.";
    Editable = false;
    PageType = List;
    PromotedActionCategories = 'New,Process,Report,Entry';
    SourceTable = "Item Ledger Entry";
    SourceTableView = SORTING("Entry No.")
                      ORDER(Descending) where("Entry Type" = filter('Positive Adjmt.|Purchase'));
    UsageCategory = History;

                ShowCaption = false;
                field("Entry Type"; "Entry Type")
                    ApplicationArea = Basic, Suite;
                    ToolTip = 'Specifies which type of transaction that the entry is created from.';
              field("Item No."; "Item No.")
                    ApplicationArea = Basic, Suite;
                    ToolTip = 'Specifies the number of the item in the entry.';
               field("Posting Date"; "Posting Date")
                    ApplicationArea = Basic, Suite;
                    ToolTip = 'Specifies the quantity in the Quantity field that remains to be processed.';
                    Visible = true;
                    Caption = 'Posting Date';
                 field(QtyAvail; RemQtyILE)
                    ApplicationArea = Basic, Suite;
                    ToolTip = 'Specifies the Qty. Available in the field that links to Reservation entries table quantity field.';
                    Visible = true;
                    Caption = 'Qty. Available';
                    trigger OnValidate()


    trigger OnAfterGetRecord()
        ItemAttr: Record Item;
        ItemLedEntry: Record "Item Ledger Entry";
        ItemAttr.SetRange("No.", "Item No.");
        If ItemAttr.findfirst then begin
            Inv := ItemAttr.Inventory;
            ItemAttr.CALCFIELDS("Qty. on Sales Order");
            qtySO := ItemAttr."Qty. on Sales Order";
            RemQty := Inv - qtySO;
        if ItemAttr."No." <> ItemLedEntry."Item No." then begin
            If ItemLedEntry.FIND('-'then begin
                until ItemLedEntry.Next = 0;
                RemQtyILE := RemQty;

        ItemAttr: Record Item;
        RemQty: Decimal;
        RemQtyILE: Decimal;
        Inv: decimal;
        qtySO: Decimal;


I am getting 972. in each row. I wanted it only in last row in last entry each time. Any help.
  • Suggested answer
    Andy Sather Profile Picture
    Andy Sather on at
    RE: AL code:- Update value in a last row of item ledger entry page based on Item page data

    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.



    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 Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…


Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,068 Super User

Martin Dráb Profile Picture

Martin Dráb 222,591 Super User

nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans