web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

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

(0) ShareShare
ReportReport
Posted on by
Hi,
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;

    layout
    {
        area(content)
        {
            repeater(Control1)
            {
                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()
                    begin
                        CurrPage.Update();
                    end;
                }

            }
        }
       
    }

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

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

}
8510.Capture.PNG

I am getting 972. in each row. I wanted it only in last row in last entry each time. Any help.
I have the same question (0)
  • Suggested answer
    Andy Sather Profile Picture
    on at

    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.

     

    https://www.yammer.com/dynamicsnavdev#/home

    https://dynamicsuser.net/nav/f/developers

     

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans