Skip to main content

Notifications

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

Posted on by Microsoft Employee
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
    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.

     

    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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,275 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans