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...
Unanswered

I have written this code for a report in business central to fetch debit credit amount and opening and closing balance between two dates specified by user on request page.But report in preview mode is not opening at all.

(0) ShareShare
ReportReport
Posted on by 234

I have written this code for a report in business central to fetch debit credit amount and opening and closing balance between two dates specified by user on request page.But report in preview mode is not opening at all.

report 90139 MyReport
{
    Caption = 'Ledger Confirmation Report';
    PreviewMode = PrintLayout;
    UsageCategory = Administration;
    ApplicationArea = All;
    DefaultLayout = RDLC;
    RDLCLayout = './Reports/LedgerConfirmationRepo.rdl';

    dataset
    {
        dataitem(Customer_table; Customer)
        {
            RequestFilterFields = "No.";

            column(OpeningBalance; OpeningBalance) { }

            column(ClosingBalance; ClosingBalance) { }

            dataitem(Cust_ledgerEntry; "Cust. Ledger Entry")
            {
                DataItemLink = "Customer No." = field("No.");
                column(Debit_Amount; Cust_ledgerEntry."Debit Amount") { }
                column(Credit_Amount; Cust_ledgerEntry."Credit Amount") { }
                column(Date; Cust_ledgerEntry."Posting Date") { }

                column(Particulars; Cust_ledgerEntry.Description) { }
            }
            trigger OnAfterGetRecord()
            begin
                CustLedgerEntry.Reset();
                CustLedgerEntry.SetRange("Customer No.", "No.");
                // CustLedgerEntry.SetFilter("Posting Date", '..%1', CalcDate('<-1D>', PostingDateFrom));
                // CustLedgerEntry.CalcSums(Amount);
                // OpeningBalance := CustLedgerEntry.Amount;
                CustLedgerEntry.SetFilter("Posting Date", '%1..%2', PostingDateFrom, PostingDateTo);
                CustLedgerEntry.CalcSums("Debit Amount", "Credit Amount");
                DebitAmount := CustLedgerEntry."Debit Amount";
                CreditAmount := CustLedgerEntry."Credit Amount";
                ClosingBalance := OpeningBalance + DebitAmount - CreditAmount;
               //C00050
            end;

        }
    }



    requestpage
    {
        SaveValues = true;
        layout
        {
            area(content)
            {
                group(GroupName)
                {
                    Caption = 'Date Filter';
                    field("Posting Date From"; "PostingDateFrom")
                    {
                        ApplicationArea = all;
                        Caption = 'Posting Date From';
                        ShowMandatory = true;
                        ToolTip = 'Specifies the date from you want the calculated for.';
                    }
                    field("Posting Date To"; "PostingDateTo")
                    {
                        ApplicationArea = all;
                        Caption = 'Posting Date To';
                        ShowMandatory = true;
                        ToolTip = 'Specifies the date to which you want the aging calculated for.';
                    }

                }
            }

        }
    }
I have the same question (0)

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,926 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,158 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 533 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans