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

Values are not assigning in last variable

(1) ShareShare
ReportReport
Posted on by 92

report 54082 "AR16.2-DailyCollectionSummary"
{
    UsageCategory = ReportsAndAnalysis;
    ApplicationArea = All;
    DefaultLayout = RDLC;
    RDLCLayout = './src/Report/Layout/Rep54082.AR162DailyCollectionSummary(BG).rdl';
    Caption = 'Daily Collection Summary(BG)';

    dataset
    {
        dataitem(CustLedgerEntry; "Cust. Ledger Entry")
        {
            DataItemTableView = sorting("Posting Date") WHERE("Document Type" = FILTER(Payment));

            column(Posting_Date; "Posting Date")
            {

            }

            column(NCash; NCash)
            {

            }

            column(NChq; NChq)
            {

            }

            column(ReturnChq; ReturnChq)
            {

            }

            column(DirectDeposit; DirectDeposit)
            {

            }

            column(ReturnDirecDep; ReturnDirecDep)
            {

            }

            column(PdChq; PdChq)
            {

            }

            column(OtherPayment; OtherPayment)
            {

            }

            column(OtherReturns; OtherReturns)
            {

            }

            column(FromDate; FromDate)
            {

            }

            column(ToDate; ToDate)
            {

            }

            //company infromation
            column(CompanyName; CompanyInfoRec.Name)
            {

            }

            column(Company_Address; CompanyInfoRec.Address)
            {

            }

            column(Company_Address1; CompanyInfoRec."Address 2")
            {

            }

            trigger OnPreDataItem()
            begin

                //Filter Using Type Of Payment
                CustLedgerEntry.SetFilter("Payment Method Code", '%1|%2|%3', 'CASH', 'CHEQUE', 'CUSDEP');

                //Taking Only Payment Details
                CustLedgerEntry.SetFilter("Document Type", '%1', "Document Type"::Payment);

                //Date Range
                if (FromDate <> 0D) and (ToDate <> 0D) then
                    CustLedgerEntry.SETFILTER("Posting Date", '%1..%2', FromDate, ToDate);
            end;

            trigger OnAfterGetRecord()
            begin

                NCash := 0;
                NChq := 0;
                ReturnChq := 0;
                DirectDeposit := 0;
                ReturnDirecDep := 0;
                OtherPayment := 0;
                OtherReturns := 0;
                PostingDate := 0D;

                GenJournalLine.Reset();

                CalcFields("Amount (LCY)");

                //Cash Payment
                if "Payment Method Code" = 'CASH' then
                    NCash := "Amount (LCY)"

                //Cheque Payment
                else
                    if ("Payment Method Code" = 'CHEQUE') and (Reversed = false) then
                        NChq := "Amount (LCY)"

                    //Return Cheque
                    else
                        if (("Payment Method Code" = 'CHEQUE') and (Reversed = true)) then
                            ReturnChq := "Amount (LCY)"

                        //Direct Deposit
                        else
                            if (("Payment Method Code" = 'CUSDEP') OR ("Payment Method Code" = 'DP')) and (Reversed = false) then
                                DirectDeposit := "Amount (LCY)"

                            //Return Direct Deposit
                            else
                                if (("Payment Method Code" = 'CUSDEP') OR ("Payment Method Code" = 'DP')) and (Reversed = true) then
                                    ReturnDirecDep := "Amount (LCY)"

                                //Other Returns    
                                else
                                    if Reversed = true then
                                        OtherReturns := "Amount (LCY)"
                                    else
                                        OtherPayment := "Amount (LCY)";

                //PDC Cheque(Need To check with gayan)
                if PostingDate <> "Posting Date" then begin
                    PostingDate := "Posting Date";
                    PdChq := 0;
                end;

                GenJournalLine.SetRange(GenJournalLine."Posting Date", PostingDate);
                //GenJournalLine.SetRange(GenJournalLine."Journal Batch Name", 'DEFAULT');
                GenJournalLine.SetRange(GenJournalLine."Journal Template Name", 'PDC');
                if GenJournalLine.FindSet() then begin
                    repeat
                        PdChq  = GenJournalLine."Amount (LCY)";
                    until GenJournalLine.Next() = 0;
                end;

            end;

        }
    }
    requestpage
    {
        layout
        {
            area(content)
            {
                group("Posting Date")
                {
                    field("From Date"; FromDate)
                    {
                        ApplicationArea = All;

                    }

                    field("To Date"; ToDate)
                    {
                        ApplicationArea = All;

                    }
                }
            }
        }
        actions
        {
            area(processing)
            {
            }
        }
    }

    trigger onprereport()
    begin
        CompanyInfoRec.Get();

    end;

    var
        CompanyInfoRec: Record "Company Information";
        GenJournalLine: Record "Gen. Journal Line";
        FromDate: Date;
        ToDate: Date;
        PostingDate: Date;
        NCash: Decimal;
        NChq: Decimal;
        PdChq: Decimal;
        ReturnChq: Decimal;
        NetChq: Decimal;
        DirectDeposit: Decimal;
        ReturnDirecDep: Decimal;
        NetDirDep: Decimal;
        OtherPayment: Decimal;
        OtherReturns: Decimal;
}
 

values are not assigned to variable "OtherPayment" 

*This post is locked for comments

  • Lars Lohndorf-Larsen Profile Picture
    Microsoft Employee on at

    Hi,

    I see it should be assigned here:

    ===

                                   //Other Returns    

                                   else

                                       if Reversed = true then

                                           OtherReturns := "Amount (LCY)"

                                       else

                                           OtherPayment := "Amount (LCY)";

                   //PDC Cheque(Need To check with gayan)

    ===

    As a simple check you could try to add CONFIRM to see if that branch of the code runs at all to begin with. For example:

                                       else

                                           BEGIN

                                           OtherPayment := "Amount (LCY)";

                                            IF NOT CONFIRM(FORMAT(OtherPayment)) THEN ERROR('Stop.');

                                           END;

    Note: I have not checked either syntax or functionality of this code.

    You can use MESSAGE instead of CONFIRM, but if this is inside of a loop of for example Customer ledger enries, the CONFIRM gives you a chance to cancel the report as opposed to saying OK to a lot of MESSAGE boxes.

    So this is probably how I would start trouleshooting this, I hope it gives you some ideas.

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 Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 740 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 531 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 310 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans