This article describes a setup-based solution for emailing reports with additional attachments from D365FO. We will show a step-by-step configuration which enables you to email an invoice with Terms & Conditions and product specification as additional attachments from D365FO.
Before writing this post, I tried to find other articles on similar topic, in particular: how to email an invoice with Terms & Conditions. I found a few solutions around the idea to embed the Terms & Conditions (T&Cs) content into the report datasource and then print it as the integral part of the generated document. This solution is elegant but requires development in order to customize the report datasource and design. Another possible solution is to attach T&Cs to the outgoing email as a separate file, but you have to automate this process through development too, otherwise you can say goodbye to batch processing. In short, no matter which way you want to email T&Cs alongside your invoices, you will need to utilize the developers. And this is costly, right?
Fortunately, with Docentric you can email your reports with additional attachments with zero lines of code. You can specify which documents should be attached to outgoing emails from within D365FO, directly on the Print destination settings form. The documents that you can select are just regular Attachments from built-in Document management, stored using regular Document types and attached to legal entities, sales and purchase orders, customers and vendors, etc.
Let’s take a closer look how this setup works, and how to configure the emailing process so that we can attach a few additional documents to our outgoing emails along the printed invoice. In our example on how to email an invoice with additional attachments from D365FO, we will use the following additional attachments:
- T&Cs: we want to always use the same document regardless of the invoice, and
- Invoice-specific specification documents.
Terms & Conditions as Additional attachment
T&Cs is a document that you would typically attach to a legal entity.
Notice the Docentric settings tab, added to the standard D365FO Attachments form. The Report attachments group contains the parameters which allow for fine-tuning when selecting Additional attachments. Only those Legal entity attachments that are marked as Global attachment will be considered as candidates for Additional attachments.
Now we need to configure our Sales invoice report so that this T&Cs document is also attached when the report is emailed. This is done in Print management setup for Sales invoice, on the Print destination settings form > Email > Additional attachment rules:
By clicking the Modify button a new form is opened, where we can specify the rules for picking the additional attachments for this report.
The image below shows a possible rule setting for attaching the T&Cs document:
Load from is set to Global attachments, which tells the system to search for the files attached to the current legal entity. From all the available legal entity attachments, those matching the Attachment description, File type, Restriction and Language will be used. There is exactly one such attachment on my system and the recipient will get the email message as in the image below. The first attachment is the report and the second attachment is the T&Cs document:
Notice that we want to make sure that the T&Cs document is always sent, therefore we have configured the If not found setting to raise an error if no matching document is found at the moment of preparing the email message. (Think of this scenario: you have configured the additional attachment rule which points to a document of interest, but the document is deleted or renamed prior to printing, thus no matching attachment would be found when the report is printed).
Invoice-specific documents as Additional attachments
Previously we demonstrated how we can point to the known Global attachments which we want to add to our email messages, but that is not all we can do. We can also define the rules for dynamically picking the additional attachments in runtime, based on the actual invoice being printed. Let’s say that we are interested in some documents attached to the related Sales order. The below image shows an example of documents on Sales order and we want those having the Specification category to be also added when we email the Sales invoice report.
We will need to add a new Additional attachment rule:
As we are printing the Sales invoice report, Source table will be resolved as the underlying Sales order. From all the attachments on the linked Sales order, we will take only those marked with the Specification category, we will ignore the Restriction and the Language settings, and as these are not mandatory attachments (as T&Cs was), we won’t show any warning or error if no matching document is found on the underlying Sales order. Based on this rule and the above attachments, recipient will get the following email:
As in the previous example, the first attachment is the Sales invoice report itself, and the second attachment is the T&Cs document (the result of the first rule). In addition, two new documents are attached, as marked above, and they are the result of the second rule.
That’s it! Two configuration lines on the Docentric Email print destination settings and we have email with T&Cs and invoice-specific attachments. We can cover many other scenarios by using various attachment sources in the Load from field and different filter conditions.