Skip to main content

Notifications

Announcements

No record found.

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 308

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

  • Suggested answer
    Greg Enns Profile Picture
    1,102 on at
    RE: How to daisy-chain a report - open a different report after a first report?

    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.

  • Suggested answer
    YUN ZHU Profile Picture
    78,733 Super User 2025 Season 1 on at
    RE: How to daisy-chain a report - open a different report after a first report?

    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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,760 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans