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.
  • Suggested answer
    Andy Sather Profile Picture
    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.

     

    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,760 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans