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...
Suggested Answer

How to daisy-chain a report - open a different report after a first report?

(0) ShareShare
ReportReport
Posted on by 397

Hi Everyone:

I've got a weird one here.  The situation: I'm trying to open the original invoice to which a payment has been applied, and I want to open it right after a receipt report that I've built (custom) is run for the payment.  You can assume a one-to-?one relationship between the payment and the invoice.  So basically, I run my receipt (report) for payment 123, it prints the receipt, and I want a copy of the invoice to which payment 123 was applied which is number ABC4.

I'm not averse to trying to put these into the same report and conditionally hiding the invoice portion if the payment was unapplied - that unfortunately presents an almost vertical barrier to entry on this because my client has multiple invoice types and I really don't feel like messing around replicating logic.  

What I've tried is this:

            trigger OnPostDataItem()
            begin
                if "Applies-to Doc. No." <> '' then begin
                    // replacement token initializations
                    ReplacementToken := '%INVOICE_NUMBER%';

                    // semi-constant initializations
                    CoreParameterString := '<parameters here that run this report>';
                    CoreParameterString := CoreParameterString.Replace(ReplacementToken, "Applies-to Doc. No.");
                    Report.Execute(Report::"Standard Sales - Invoice", CoreParameterString);
                end
            end;

But it simply does nothing - if I had to guess, it might spawn a report in a background session and never present it to the user, or it just ignores the code.  Either way, it's effectively telling me to go stuff myself.

Is there a way to actually do what I'm thinking?  Anyone got any ideas?

Thanks.

-J

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    101,948 Super User 2026 Season 1 on at

    Hi, I think you can research the standard code, the report is executed sequentially in Report Selection.

    pastedimage1682551794792v1.png

    Hope this can give you some hints.

    Thanks.

    ZHU

  • Suggested answer
    Greg Enns Profile Picture
    1,122 on at

    A few ideas...

    - Did you try running the debugger on it to see if the report is maybe executing but something with the parameters is causing it to return nothing?

    - Trying to run report B while in the middle of running report A, may be the issue here. Solution to that would be to collect your data during the receipt report (probably using a single-instance codeunit), and then subscribe to an event AFTER the ReceiptReport.Run to then run your report using the collected data.

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 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,250 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,799 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,390

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans