Skip to main content
Business Central forum
Answered

Printing 2 reports in a sequence business central

editSubscribe (0) ShareShare
ReportReport
Posted on by 145

Hi guys, 

I am having a problem with printing 2 reports (sales shipment and sales invoice) in a sequence by manually calling the print records functions on the respective records in BC20 On Premises. Its only printing the second report but both documents are incrementing the number printed field.

Any idea what could be causing this? 

Categories:
  • Rebe.Gwaindepy Profile Picture
    Rebe.Gwaindepy 145 on at
    RE: Printing 2 reports in a sequence business central

    Hi guys,

    it looks like this is not possible as of now because of browser limitations:

    docs.microsoft.com/.../report-run-method

  • Verified answer
    Rebe.Gwaindepy Profile Picture
    Rebe.Gwaindepy 145 on at
    RE: Printing 2 reports in a sequence business central

    Thank you, if all fails then i will have to go this route.

  • Rebe.Gwaindepy Profile Picture
    Rebe.Gwaindepy 145 on at
    RE: Printing 2 reports in a sequence business central

    My report selections is defined ok with report 1308 for D Note. If i flip the code to print invoice first, then it will print D notes only. I have also debugged and indeed the system is calling the reports (and they increment No. printed). Is your post and print function for Cash receipt journal printing both GL register and Customer payment report?

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 59,873 Super User on at
    RE: Printing 2 reports in a sequence business central

    Hi, I'm not sure if this will help you, I have used the solution below to combine different reports into the one PDF and letting the client print this PDF.

    Merge PDF in Business Central (linkedin.com)

    Source: GitHub - gonzaloriosley/Merge-PDF-Business-Central

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,714 Super User on at
    RE: Printing 2 reports in a sequence business central

    Could not find anything obvious in the code.

    Have you defined a report for the sales shipment in report selection sales?

    The printrecord function seems to depend on what is defined in report selection sales.

    And have you checked with printrecord(true) to check if the request form actually is executed?

  • Rebe.Gwaindepy Profile Picture
    Rebe.Gwaindepy 145 on at
    RE: Printing 2 reports in a sequence business central

    Below is the code i am using for printing(i am calling this procedure after posting all orders and i commit):

       procedure PrintDispatchDocuments(DeliveryOrderHeader: Record "ADV Delivery Order Header"; )

       var

           SalesShipmentHeader: Record "Sales Shipment Header";

           SalesInvoiceHeader: Record "Sales Invoice Header";

       begin

           //>> Delivery Notes

           SalesShipmentHeader.reset();

           SalesShipmentHeader.SetRange("Delivery Order No.", DeliveryOrderHeader."No.");

           SalesShipmentHeader.FindSet(true);

           repeat

               SalesShipmentHeader.PrintRecords(false);

           until SalesShipmentHeader.Next() = 0;

           //<<Delivery Notes

           //>> Delivery Invoices

           SalesInvoiceHeader.Reset();

           SalesInvoiceHeader.SetRange("Delivery Order No.", DeliveryOrderHeader."No.");

           SalesInvoiceHeader.FindSet(true);

           repeat

               SalesInvoiceHeader.PrintRecords(false);

           until SalesInvoiceHeader.Next() = 0;

           //<<Delivery Invoices

       end;

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,714 Super User on at
    RE: Printing 2 reports in a sequence business central

    Maybe you can share the code you are using ?

    Often easier to see whats going on then.

  • Rebe.Gwaindepy Profile Picture
    Rebe.Gwaindepy 145 on at
    RE: Printing 2 reports in a sequence business central

    Hi ZHU, thanks for the response. :-), I am a huge fan. Unfortunately for my case i cant use this feature because i a printing report 1306 and 1308.  As a side note, is there a way to call post and print for a number of orders in a sequence with Commit Suppressed?

  • Rebe.Gwaindepy Profile Picture
    Rebe.Gwaindepy 145 on at
    RE: Printing 2 reports in a sequence business central

    I am using the print to pdf printer as my default printer on my machine and it automatically downloads the files. I am certain they are not being saved elsewhere.

  • Rebe.Gwaindepy Profile Picture
    Rebe.Gwaindepy 145 on at
    RE: Printing 2 reports in a sequence business central

    Hello everyone, thanks for the responses. My situation is like this: We have Shipment and Delivery addition to the Sales process that combines various sales orders to one "Delivery Order" for shipment and Invoicing, so when the user Dispatches the delivery order it posts all sales orders and afterwards Prints the Shipments  and Invoices using the Record.PrintRecords function . Everything is going well up to the point of printing, BC is only printing the last print command (Invoices). The No. printed for shipment is increasing (i can see the print command is running)  but somehow the actual print does not happen.

    In the meantime i had to put a confirmation of print After the Shipments command and they all print fine, for now. I would appreciate if you suggest another way i can handle this.

    I see an almost similar issue was reported here but on BC15 here.

    pastedimage1660758323504v1.png

    I have attached a screenshot for a better overview of the process.

    Thanks,

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Sundar…

Industry experts answer burning questions directly from our amazing Community…

Enabling Copilot Case and Conversation…

Agents can easily recap an ongoing chat, transcribe a voice conversation…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,030 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans