Save PDF Documents from D365FO in Cloud to Local File System

Save PDF Documents from D365FO in Cloud to Local File System

UPDATE TO THIS ARTICLE

From Docentric version 3.4.3, saving reports to configurable Azure file shares is supported. You can mount an Azure file share as a network drive and this way enable routing from D365FO in the cloud to your local network.

Docentric introduces a new printing option Print as PDF that enables routing of PDF files from Dynamics 365 for Finance and Operations in the cloud to the local file system, for example a shared network folder.

The Print as PDF feature can be used only when DRA (Document Routing Agent) is running as a Windows service. To fully understand the mechanism behind it, please read our previous article explaining DRA in great depth.

Print as PDF is part of Docentric Free Edition, which you can download and use right away.

Print Customer invoice to a network folder

Let’s say that we want to post and print our invoices in D365FO in the cloud to the local file system, e.g. to a shared folder in our corporate network. For the same reason that we can't print D365FO documents on network printers, we can't save them to the local file system either.

By analyzing how D365FO prints checks via DRA running as a service, we noticed that there is a hidden property in the print settings, which triggers DRA to route PDF documents to a preconfigured local folder instead of printing them.

Learn more about how DRA works >>

We exposed this property Print as PDF to be settable on the Print destination settings form > Docentric Printer print destination, so with Docentric Free Edition you can now route any report (not just the Cheque report) to local folders.

In this article, we will explain how to print invoices to a shared network folder.

Prerequisites: DRA needs to run as a service, and a shared network folder should be configured as the target folder in the DRA setup form. DRA service's account must have the Write permission for the DRA target folder.

 

Set up the print settings for Customer invoice

In Print management setup, select Docentric Printer print destination and turn on the Print as PDF option. In PDF output filename we will use placeholders @COMPANYID@, @InvoiceAccount@ and @InvoiceId@, e.g. @COMPANYID@_@InvoiceAccount_@InvoiceId@.pdf to make it dynamic.

Each report sent for printing is logged into Document routing status along with PDF output filename, and by making it dynamic, we will be able to filter the log table later by, e.g. Invoice ID and Account ID.

Run the Customer invoice report

Before we run the Customer invoice report, we will stop the DRA service, just to observe the Document routing status log. Next, we will run multiple invoices from Invoice journal. The invoices are generated and sent to the selected printer as PDF documents.

 

Note that the printer selection when printing reports using Print as PDF only affects which DRAs will handle them; those DRAs have the selected printer on their printer list.

We can also see that new records are created in the Document routing status table, containing the corresponding PDF output filenames in the Report name field, while Job status is set to Pending.

 

Now start the DRA service and see what will happen next. This is the expected result.

 

Remember, if you print Customer invoice using Docentric Printer print destination with the Print as PDF option turned on, but DRA runs as a desktop app, the invoice document will be printed to the selected network printer via Adobe Acrobat Reader. Learn why >>

Troubleshooting if the document routing is not working

If no document is routed to the target folder nor printed to the target printer, you will notice that Job status is unchanged, i.e. it is still set to Pending in Document routing status. To learn more about the possible issues, check the logs within DRA.

There is more

If you want to route any PDF document from D365FO in the cloud to the local file system, you can achieve this by using Docentric APIs, which are also part of Docentric Free Edition.

Let’s demonstrate this on a simple example. Assume that we need to save all PDF documents from Attachments of a particular sales order to a shared network folder.

 

The following code will accomplish the task.

After we configured DRA to point to the wanted local folder and ran it as a service, we can execute the above code and check the result.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>