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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Report Extension >> Customer Statement (1316) >> Filtering the Dataset to show only Open amounts

(0) ShareShare
ReportReport
Posted on by

I've been developing a report extension for our finance department. The default 1316 report is like a bank statement, showing all activity on the account. Their requirement is for it to only show Open entries. I've tried a number of different ways of doing this, but can't seem to get it to show only invoice amounts that are outstanding. 

I've tried adding a DataItemLink to the ledger entries and then filtering based on the remaining amount field; I've also tried using the PreDataItem trigger and the OnAfterGetRecord to set the range and tried setting the filter, but the report keeps showing transactions with a remaining amount of 0.

I had a look at the AL code from the Base Application, and weirdly it already seems to be doing the exact thing I want it to do, so I can't figure out why it isn't filtering out the amounts that are 0. 

// CODE FROM StandardStatement.Report.al

dataitem(CustLedgEntry2; "Cust. Ledger Entry")
{
    DataItemLink = "Customer No." = FIELD("No.");
    DataItemLinkReference = Customer;
    DataItemTableView = SORTING("Customer No.", Open, Positive, "Due Date");
    column(OverDueEntries; StrSubstNo(OverdueEntriesLbl, TempCurrency2.Code))
    {
    }

... {lots of column definitions, truncated for brevity}

    trigger OnAfterGetRecord()
    var
        CustLedgEntry: Record "Cust. Ledger Entry";
    begin
        if IncludeAgingBand then
            if ("Posting Date" > EndDate) and ("Due Date" >= EndDate) then
                CurrReport.Skip();
        CustLedgEntry := CustLedgEntry2;
        CustLedgEntry.SetRange("Date Filter", 0D, EndDate);
        CustLedgEntry.CalcFields("Remaining Amount");
        "Remaining Amount" := CustLedgEntry."Remaining Amount";
        if CustLedgEntry."Remaining Amount" = 0 then
        CurrReport.Skip();

        if "Due Date" >= EndDate then
            CurrReport.Skip();

Any help would be appreciated!

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    159 on at

    What about this:

    reportextension 99100 "Standard Statement Edit" extends "Standard Statement"
    {
    dataset
        {
            modify(DtldCustLedgEntries)
            {
                trigger OnAfterAfterGetRecord()
                begin
                    if SkipFullyApplied(DtldCustLedgEntries) then
                        CurrReport.Skip;
                end;
            }
        }
        procedure SkipFullyApplied(var DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"): Boolean
        var
            CustLedgEntry: Record "Cust. Ledger Entry";
        begin
            CustLedgEntry.Get(DetailedCustLedgEntry."Cust. Ledger Entry No.");
            CustLedgEntry.SetRange("Date Filter", 0D, EndDate);
            CustLedgEntry.CalcFields("Remaining Amount");
    
            if CustLedgEntry."Remaining Amount" = 0 then
                exit(true);
    
            exit(false);
        end;

  • Suggested answer
    AkaiRingo3559 Profile Picture
    on at

    You are an absolute legend! Works perfectly. Super quick response!

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May 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,222 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,603 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,186 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans