Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

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

Posted on by 294

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
    Greg Enns 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
    YUN ZHU 73,565 Super User 2024 Season 2 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans