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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Business Central – How to Add More Buckets to Aged Accounts Receivable Report Extension

(8) ShareShare
ReportReport
Posted on by 133
 
Hello
 
I am desperately looking for some help here.  ,  I have tried using the code suggested in another question  to add additional buckets and the below is the code . I also tried to edit the layout to include the additional fields please see attached . However the report is not populating the additional buckets (Aged91To120 & Aged121Plus fields). If this is not the right approach what would be the work around.
 
Thanks in advance 
reportextension 50100 "Aged AR Ext2" extends "Aged Accounts Receivable"
{
    dataset
    {
        add(Customer)
        {
            column(Aged91To120; CalculateAgedAmount(Customer, 91, 120))
            {
            }
            column(Aged121Plus; CalculateAgedAmount(Customer, 121, 99999))
            {
            }
        }
    }
 
    local procedure CalculateAgedAmount(
        CustRec: Record Customer;
        FromDays: Integer;
        ToDays: Integer
    ): Decimal
    var
        CustLedgerEntry: Record "Cust. Ledger Entry";
        DueDate: Date;
        AgedAmount: Decimal;
    begin
        AgedAmount := 0;
 
        CustLedgerEntry.SetCurrentKey("Customer No.", Open, "Due Date");
        CustLedgerEntry.SetRange("Customer No.", CustRec."No.");
        CustLedgerEntry.SetRange(Open, true);
 
        if CustLedgerEntry.FindSet() then
            repeat
                DueDate := CustLedgerEntry."Due Date";
                if DueDate <> 0D then
                    if (DueDate <= (WorkDate - FromDays)) and
                       (DueDate > (WorkDate - ToDays)) then
                        AgedAmount += CustLedgerEntry."Amount (LCY)";
            until CustLedgerEntry.Next() = 0;
 
        exit(AgedAmount);
    end;
}
RDLC_DESIGN.JPG
 
I have the same question (0)
  • Suggested answer
    Dhiren Nagar Profile Picture
    2,890 Super User 2026 Season 1 on at
    Hi,
     
    I think there are multiple corrections required in your code.
     
    First I think you should not add another data item and use existing once by understanding the source report code.
     
    Also in your procedure you are not using CalcFields on Flowfields i.e. Amount (LCY). You will not get values in report if you do not use it.
     
    Regards,
    Dhiren.
  • RD-11011729-0 Profile Picture
    133 on at
    Hi, 
     
    Sorry I am not clear on this, please could you give a little more detail on the below statement please
     
    "First I think you should not add another data item and use existing once by understanding the source report code."
  • Suggested answer
    NAV_with_Narang Profile Picture
    2,384 Moderator on at
    Hi @RD-11011729-0 - The answer to your question lies in understanding how Microsoft creates buckets in this report. Your task is to copy paste the report and mimic the exact same logic with a slightly different date range filtering for your additional buckets. Your code as it is, won't work
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    22,468 Super User 2026 Season 1 on at
    To add extra aging buckets, you must create a custom report by copying the standard Aged Accounts Receivable report and adding the bucket logic in AL. A reportextension + RDLC change alone is not sufficient.
  • RD-11011729-0 Profile Picture
    133 on at
    Hi, I've tried but I cannot figure out how to copy the standard Aged Accounts Receivable report and add the aging bucket AL logic. Can someone please assist? 
     
    Thanks.
     
  • Suggested answer
    OussamaSabbouh Profile Picture
    16,779 Super User 2026 Season 1 on at
    Hello,
    The additional buckets stay empty because Report 120 doesn’t output aging values from the Customer dataitem—the layout is driven by other dataitems/buffers that calculate the standard buckets, so adding columns on Customer won’t populate; additionally, the logic should use the report’s “Aged as of” date (not WorkDate) and Remaining Amount (LCY) with proper CalcFields to match standard aging. The practical fixes are to add the buckets on the same dataitem that produces the standard aging values, or copy the report to a custom one and extend the aging logic properly (or use the Excel aging report if acceptable).
    Regards,
    Oussama Sabbouh
  • RD-11011729-0 Profile Picture
    133 on at
     
     
    How do I copy the Standard report to a custom one to extend the aging buckets. I tried several ways to find the codes of the standard report to copy and make a custom one and did not have any joy. Appreciate your help with briefly letting me know the steps to copy the standard report. 
  • Suggested answer
    YUN ZHU Profile Picture
    101,502 Super User 2026 Season 1 on at
    Hi, I've done similar customizations before, and I hope the following information can give you some hints.
        trigger OnAfterGetRecord()
        begin
            Day_30 := CalCustomerBalance('<-30D>', Today);
            Day_60 := CalCustomerBalance('<-60D>', Today);
            Day_90 := CalCustomerBalance('<-90D>', Today);
            BeforeDay_90 := CalCustomerBalance('<-99Y>', CalcDate('<-90D>', Today));
        end;
    
        var
            Day_30: decimal;
            Day_60: decimal;
            Day_90: decimal;
            BeforeDay_90: decimal;
    
        local procedure CalCustomerBalance(Expr: Text[30]; ToDate: Date): Decimal
        var
            CustLedgerEntries: Record "Cust. Ledger Entry";
            TargetDate: Date;
            TotalAmount: Decimal;
        begin
            CustLedgerEntries.Reset();
            Clear(TargetDate);
            TotalAmount := 0;
            TargetDate := CalcDate(Expr, Today);
            CustLedgerEntries.SetRange("Customer No.", Rec."No.");
            CustLedgerEntries.SetRange("Posting Date", TargetDate, ToDate);
            CustLedgerEntries.SetRange(Open, true);
            CustLedgerEntries.SetAutoCalcFields(Amount);
            if CustLedgerEntries.FindSet() then
                repeat
                    TotalAmount := CustLedgerEntries.Amount + TotalAmount;
                until CustLedgerEntries.Next() = 0;
            exit(TotalAmount);
        end;
     
    Thanks.
    ZHU

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,260 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,515 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,373

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans