PDF Archive
The PDF Archive feature allows you to automatically archive documents when printing or when emailing the document. Each report based on the report selections can be archived automatically.
For example: If you have enabled the PDF Archive feature for Sales Order Confirmation documents, the PDFs that are printed or emailed will be stored to the remote file storage location automatically and be visible as new document archive file in the Document Archive Files factbox.
PDF Archive Method¶
In the Document Archive Setup page you can adjust The PDF Archive Method to specify whether the PDF Archive feature should be enabled and how conflicts should be handled. The PDF Archive Method setting has the following options:
Archive Method | Archiving | Note |
---|---|---|
Do not archive | No automatic archiving activated | This is the default. |
Always create new | A new file will be created, existing files will NOT be overwritten | |
Overwrite existing | If there is an existing file with the same remote file name, the existing file will be overwritten by the new file |
PDF Archive Category¶
Documents that are archived via the PDF Archive feature are grouped into a category. The category that will be used is determined by the Use Category setting in the PDF Archive section in the setup:
Use Category Selection Method | Initial Category | Note |
---|---|---|
Report Selection Category | The PDF Category Code of the report selection for the document type/report selection usage is used. | |
PDF Category | The PDF Category Code from the setup is used. Only when this option is selected, field PDF Category Code can be changed. | PDF Category Code is mandatory when this option is chosen. |
Default Category | The Default Category Code from the setup is used. |
PDF Archive Scenarios¶
You can use the PDF Archive Scenarios tab to specify when the PDF Archive feature should archive documents. Print and Email are the default values, which can be restored using the Restore Defaults action in the Document Archive Setup page.
The available options are as follows:
-
Print - When a document is printed, the PDF file will be stored. Note that the PDF is also archived when the print action is handled by the browser, i.e., this is not restricted to cloud printers (anymore).
-
Preview - When a document is previewed, the PDF file will be stored.
-
Save - When a document is saved, the PDF file will be stored.
-
Download - When a PDF file is downloaded, the PDF file will be stored.
-
E-mail - When a PDF file is generated for e-mail attachment, the PDF file will be stored.
The default is set to Print and E-mail, which means that when a document is printed or e-mailed (i.e., as PDF file attachment), then the PDF file will be stored in the document archive remote file location.
Document Archive also logs the scenario for which the PDF file was archived (on the Document Archive File record), so that you can see the reason why the file was stored to the document archive. In the Scenario field in the Document Archive Files factbox you can check the reason the PDF file was archived (e.g., due to a print, e-mail, save).
PDF Archive Document Naming¶
For Document Naming there are two options. By default, the name of the file is always started by the name of the company followed by a name depending on the setup:
-
Report Caption: The caption of the report object is used followed by the document's number. For example. "Sales - Invoice SI12345".
-
Document Type: Business Central's default document naming is used followed by the document's number. For example, "Invoice SI12345".
Settings per Report Selection¶
The PDF Archive feature settings cannot only be configured on the Document Archive Setup page, but also on report selection level. You can access the settings on the report selection level on the Report Selection pages in Business Central.
In the screenshot (marked in red) you will see the settings available on report selection level, i.e., you can adjust the PDF Archive method and the Category Code to use for this report selection specifically.
On report selection level, the PDF Archive Method setting has the following options:
Archive Method | Archiving | Note |
---|---|---|
Do not archive | No automatic archiving activated | This is the default. |
Always create new | A new file will be created, existing files will NOT be overwritten | |
Overwrite existing | If there is an existing file with the same remote file name, the existing file will be overwritten by the new file | |
Use default | Simply use the settings from the Document Archive Setup. (Default) |
Note
Field Document Archive Category Code will only be visible when the option Report Selection Category for setup field Use Category is selected in the Document Archive Setup page.
Attach as PDF Action¶
If you use the standard Attach as PDF action it will react according to the setup of PDF Archive feature.
- Documents for which PDF Archive is NOT enabled, will be attached to the standard Attachments
- Documents for which PDF Archive is enabled, will be uploaded to the Document Archive remote file storage and visible as files in the Document Archive Files factbox.
The "Disable Store to Database Attachments" field (Default: true) allows you to specify whether Document Archive should overrule the default Attachments feature in Microsoft Dynamics 365 Business Central (i.e., whether the Attach as PDF... action should still archive files as database-stored attachments, visible in the Attachments factbox).
Support New Document Types¶
To add support for the PDF Archive feature for a new report selection usage, please make sure your reports are printed via one of the dedicated "Report Selections".PrintWith...
procedures.
Next to that, you should add event subscribers for the following event publishers:
-
WSB_DCAFileMgt.wlEvpOnSetPrimaryValues
Allows you to specify the primary key field values given a
RecordRef
of the source table record that the file should be linked to. -
"Report Distribution Management".OnAfterGetFullDocumentTypeText
Allows you to specify the text which will be used for the document report PDF file name, given a (record-related)
Variant
of the source table record that the file will be linked to. -
"Report Distribution Management".OnGetDocumentLanguageCodeCaseElse
Allows you to specify the language code to translate the document report PDF filename into different languages, given a
RecordRef
of the source table record that the file will be linked to. -
"Electronic Document Format".OnGetDocumentNoCaseElse
Allows you to specify how to retrieve the document no. to use in the document report PDF filename, given a (record-related)
Variant
of the source table record that the file will be linked to.