Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Printing 2 reports in a sequence business central

Posted on by 160

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 160 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 160 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 160 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 64,622 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,722 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 160 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,722 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 160 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 160 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 160 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

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans