Additional Email Attachments
When you select printing a report to the Email print destination (Docentric or SSRS), this is what happens: an email message is created, the report is printed and attached to the message, which is then sent out from D365FO.
If you select the Docentric Email print destination, many improvements of the standard D365FO emailing functionality will be available to you. One of them is the possibility to specify additional attachments, which should be attached to the email message along with the report itself.
Additional attachments sources
Report attachments are in runtime loaded from the documents stored under the D365FO Document management. There are several different source (record) types from which we can load the attachments:
- Global attachments: documents attached to legal entities, having the Global flag set, are candidates for report attachments. Examples are your company legal documents like T&C. Read more about the Global attachments setup >>
- Source table: documents attached to the report source table. Report source tables are report specific and not always applicable. Here are some examples: for the Customer invoice report source table will be the Sales order table; for the Purchase order report it is the Purchase order table; for the Number of workers report, source table is not applicable.
- Account table: documents attached to the Customer table (for customer-facing reports) or the Vendor table (for vendor-facing reports). Not applicable to all reports.
- Journal: documents attached to the related journal, if applicable. For example, when printing the Customer invoice report, it will be Invoice journal; for the Purchase order report it will be Purchase confirmation journal, etc.
- Context record: represents the underlying entity (record) that the report is invoked from. Usually it will be equal to Source table or Journal table. The documents attached to this record are candidates for report attachments.
- Custom record: requires custom implementation, for example a customer specified as Order account on the related sales order when printing the Sales invoice report.
Notice that Global attachments are known already in the moment when you specify the rules for their retrieval (see Additional attachment rules), while all the other attachment source types require resolving their underlying record in runtime and retrieving the documents attached to that record. For that reason, we refer to them as Dynamic attachments.
Docentric settings on the Attachments form
The Docentric settings fast tab is added to the standard D365FO Attachments form for Document management:
It contains the following fields:
- Language: allows to refine the list of documents to be attached to the report, by matching the report runtime language with the language specified on the document.
- Category ID: enables simple way of categorizing the documents and specifying a rule for attaching all the documents marked with a given category. See Attachment categories.
- Tags: provided only for user convenience, to make it easier to describe the document purpose and to identify it later, e.g. when selecting Global attachments.
- Global attachment: visible and applicable only on the Attachments form for legal entities; see the left image above. If the attachment source is Global attachment, then only the current legal entity’s attachments with this option turned on are candidates for report attachments. For other types of the attachment sources this flag isn’t applicable.
The Docentric settings form
Notice a new menu item Global attachments (left image above) / Docentric settings (right image above) on the Attachments form. It opens a form which lists all the attachments in a tabular way, more convenient for editing. Below is the form that you can open from Attachments of the Customers form.
On the Global attachments/Docentric settings form only the last two columns (Original file name and File type) are read-only. Everything else can be edited, which provides a convenient way for maintaining the important attachment metadata used for the selection of the attachments in runtime.
Attachment categories introduced on the Attachments form are maintained through the separate Attachment categories form that you can open from the Docentric AX workspace.
From the Docentric AX workspace click the Global attachments menu item. It opens the Global attachments form:
Global attachments form provides a convenient summary overview of Global attachments per legal entity. For each of legal entities, we can see the following information in the grid:
- Number of attachments: represents the total number of attachments, both Global and Non-Global, attached to a legal entity. Equals to the number shown by the paperclip in the top right corner of the form.
- Number of Global attachments: shows the number of Global attachments (documents with the Global flag turned ON) per legal entity.
- No. per language: provides a list of all languages used on the documents with the number of documents per language.
- No. per category: gives a list of all categories used on the documents with the number of documents per category.
Notice the Global attachments menu item. It opens the form where you can view and edit all the information relevant to the report attachments (e.g. Description, Category or Language). You can also open the same form directly from Attachments on the Legal entities form.
Additional attachment rules
Which attachments should be emailed as additional attachments when emailing a report is specified directly on the Print destination settings form. What we need to do is to configure Additional attachment rules. Each rule defines the attachment source, optionally some filtering to be applied to a set of retrieved attachments, and few more parameters.
To configure Additional attachment rules, on the Docentric Email print destination open the Additional attachment rules fast tab. In the title, you will see the number of already specified rules:
Click the Modify button to open a dialog for specifying additional attachment rules:
You can configure the following rule parameters here:
- Load from: specifies the attachment source as explained in Additional attachment sources.
- Category ID: from all the documents found on the specified source, take only those with the given Category ID. If no Category ID is specified, don’t apply filtering by category.
- Attachment description: if provided, take only the documents with the matching description (The Description field on the Attachments form).
- If source is Global attachments, then this is a lookup into a list of all available global attachments for the current legal entity and the DAT legal entity. Lookup is filtered to display only the documents for the current legal entity, but the filter can be removed to display also the DAT documents.
- For any other source, this is a free editable text field, where you can specify the full attachment description (for example: "Item specification"), or only the partial description by using the wildcards * and ? (for example: "Item*", "*spec*", "?tem*", would all result in attachment with the description "Item specification" to be retrieved). You can also use the report placeholders; a list of applicable placeholders for the current report is available under the menu item Insert placeholder. For example, "@InvoiceAccount@*" on the Sales invoice report for the US-001 customer will return the documents where the description starts with US-001.
- File type: if provided, take only the documents with the matching extension (for example: pdf, docx, png, etc.)
- Restriction: retrieve only the documents with the corresponding restriction (External or Internal). Leave Both internal and external if you don’t want to filter by the restriction field.
- Language: if you are dealing with documents in different languages, then you can use additional filtering by the language specified on the document. There are following possibilities:
- Any language: choose this if you don’t want to apply any filtering by language.
- Only the matching language: select only the documents where the same language as the report runtime language is specified.
- The matching language, if not found then without language: try to find the documents with the same language as the report runtime language. Only if no such document is found, search for the documents without the language.
- Both the matching language and without language: self-explanatory, use the documents with the same language as the report runtime language and the documents without the specified language.
- If not found: select which action should be taken if no document was retrieved based on the given rule. You can cancel printing (and raise exception), or continue anyway, with or without the warning.
- Display name: specify the filename (without the file extension) which should be given to the retrieved document(s) that are going to be attached to the outgoing email. You can use placeholders; particularly useful are the first two placeholders from the Insert placeholder dropdown: @ORIGINAL_DESCRIPTION@ that stands for the Description field of the original document and @ORIGINAL_FILENAME@ that stands for the File name field of the original document. For example, "@ORIGINAL_DESCRIPTION@ – @InvoiceAccount@" for the Sales invoice report for the US-001 customer and the document with Description "Quotation" will result in the following attachment name: "Quotation – US-001".
- Resulting attachment name: the read-only result of Display name and File type representing the final filename (with the file extension) of additional attachment(s) of the outgoing email.
You can specify the order in which the rules will be processed in runtime by using the Up and Down buttons:
The first rule will be processed first, and all the documents retrieved based on this rule will be attached to the email message. Then the second rule is processed in a similar way and so on.
You can use the placeholders for Dynamic (Non-Global) attachments in the Attachment description and Display name fields. You can type in a placeholder in the position where you need it, or you can use the Insert placeholder button. The selected placeholder will be added to the end of the currently active field. Notice the first two placeholders in the right image below, they appear if the placeholder dropdown form is invoked from the Display name field.
@ORIGINAL_DESCRIPTION@ stands for Description of an attachment in the Attachments form, and @ORIGINAL_FILENAME@ stands for its File name.
Example 1: Load T&C from Global attachments
Example 2: Load from Global attachments, filter by Category
Example 3: Load all attachments from Sales table
Attachments on the related Sales table:
Example 4: Language configuration
Here is one possible way to utilize the Language parameter: you can have the Terms & Conditions document in French, Spanish and English language as 3 different attachments on your legal entity. You can specify French and Spanish language on the first two documents respectively, while you leave the English document without the language.
When you configure the rule for loading from the Global attachments, you specify the Language condition as The matching language, if not found then without language.
If the report runtime language is French or Spanish, the French or the Spanish document respectively will be attached. For all the other languages (including English), the English document will be attached.