You can print particular reports such as invoices and collection letters to Attachments of the corresponding journals only by using the e-Invoice attachment option settable on the customer card in Dynamics 365 for Finance and Operations. But what if you want to save an invoice to Attachments of the customer or sales order instead? Or if you need to reprint the invoice and replace the existing document for some reason? What if you simply want to change Document type used for e-Invoice Attachment, which always set to File?
In this article, we will explain how to print Sales invoice to Attachments of the corresponding sales order. The prerequisite is that you also have Docentric SSRS Replicas installed.
Setup for printing to Attachments
It’s very easy – just open the Print destination settings form from Print management setup for Customer invoice, and select Docentric File print destination. Then turn on the Save to Attachments option and set additional parameters Document type, target Record type and whether the attachment file content should be replaced if the attachment with the same filename already exists – see the If Attachment already exists combobox.
We selected Source table, because we want invoices to be saved to Attachments of sales orders, and in case of Sales invoice, the source table is Sales order (SalesTable). Similarly, for the Purchase order report the source table is Purchase order (PurchTable). If we selected Account table or Journal as Record type, the invoice would be saved to Attachments of the customer or the journal record respectively.
Context record refers to the record that the printing of the report is invoked from. For example, in case of Work report this is the underlaying Work record. In case of Sales invoice, Context record is always the corresponding SalesTable table.
If we print an invoice using Docentric File print destination with the previous setup, the output document will appear in Attachments of the related sales order. Note that the output filename of the attached document is Rechnung CIV-0001.pdf, which we achieved by using label @SYS14204 (translated as Invoice in English) and placeholder @InvoiceId@.
There is more
We extended Attachments with the new fields: Category, Language, Tags, Active from and Active to. These settings are useful when emailing reports with additional email attachments. Learn more >>
Moreover, in one of the next product releases, you will be able not only to select additional email attachments but also to set up which attachments you want to embed or merge to the output documents. How awesome is that!