How to Use Multiple Templates per Report
Non Print Management Reports
In Docentric report setup you can add a particular SSRS report design (e.g. HcmNumberOfWorkersReport.Report) which then becomes a Docentric report. Such a report can have multiple Docentric designs (aka Docentric templates) assigned.
Which one to use for report generation you will select directly on the Print destination settings form regardless of the currently chosen print destination as shown on the pictures below.
You can notice that in the Template ID combobox there are two tokens: @SSRS_BUILTIN_DESIGN@ and @DOCENTRIC_DEFAULT_TEMPLATE@. Afterwards, all templates from Docentric report setup are listed.
If you select the @SSRS_BUILTIN_DESIGN@ token as Template ID, the built-in SSRS report design (HcmNumberOfWorkersReport.Report) and SQL Server Reporting Services will be used to generate the report. The generated report will be then sent to the selected Docentric print destination using Docentric AX Framework.
On the other hand, if you select the @DEFAULT_DOCENTRIC_TEMPLATE@ token, when the report gets executed the default template for the current company and runtime language will be used. Considering the current state of the HcmNumberOfWorkersReport.Report report in Docentric report setup, the template with the Template ID HcmNumberOfWorkersReport.Report will be used. The report will be generated using Docentric rendering engine.
In the previous product version for AX 2012, template selection on the Print destination settings form wasn’t possible, and the default template was always used unless we didn’t change the selected template in the report DSP class, i.e. using X++. In this product version for D365FO, the concept of default template affects only Original and Copy preview for Print Management reports.
And finally, if we select any of the fixed Template IDs (i.e. which is not a token) in the Select template combobox, then exactly this Template ID will be used to resolve which template from Docentric report setup to fetch in order to generate the report, taking into account the current company and runtime language. Remember, you can have multiple templates with the same Template ID but for different companies and languages.
Print Management Reports
Let’s say that we want to use multiple templates for the Customer Invoice report, as it is described in the Title field in the Templates grid on the picture below. In short, we want to use different template for different customers, companies and/or languages.
We usually use Print Management reports in the following ways:
- For some reports such as Customer invoice when a sales order is posted, the report dialog form and the Print destination settings form can be open, where we can select the target print destination and the particular template we want to use.
- The Use print management button on journal forms enables use of the print destination settings configured in Print Management Setup. In the next section is shown how to implement the scenario described above, in which we want to use different templates for different customers.
- The Original and Copy preview buttons on journal forms enables report preview, i.e. printing report to Screen. In this case we can accomplish the wanted scenario only programmatically since the default Docentric template is always used to preview a report. Read more >>
Note that multiple templates can have the same Template ID as long as they are set up to be used with different companies and languages. This is not limited to default templates only, as we have here in our example for Customer invoice.
Print Management Setup
In Print Management Setup we can set up which template to be used when the Use print management button is clicked on a journal or some other form. If we don’t configure anything, the default template for the current company and the runtime language will be used.
Keep in mind that Print Management Setup is set per company, which means that we have to configure it for each company to achieve the wanted scenario – to use different templates for different customers. However, we can also solve this programmatically. See how >>
Thus, we set for the USMF company in Print Management Setup for the Customer invoice report in Original Default Settings @DOCENTRIC_DEFAULT_TEMPLATE@ (i.e. default template per current company and language) to be used for report generation.
We also created a special settings for the DE-001 customer (in Print Management Setup for the same USMF company), where we chose a non-default template SalesInvoice.Report_DE-001 to be used for report generation.
On the Invoice journal form, when we click the Use print management button for the invoice with the DE-001 customer, the SalesInvoice.Report_DE-001 template is going to be used to print the report.
On the other hand, if we click the Use print management button for the invoice with the US-001 customer, one of the three default templates with SalesInvoice.Report as Template ID is going to be used to print the report. Since the current company is USMF, and the runtime language is the language of the US-001 customer (which is en-us), the second template with template file SalesInvoice.Report_USMF.docx will be used for report generation.
If we change the company to, e.g. USPI and select in Print Management Setup @DOCENTRIC_DEFAULT_TEMPLATE@ or SalesInvoice.Report as Template ID for the Customer invoice report, the template with the template file SalesInvoice.Report.docx will be used for report generation.
Original and Copy Preview
If we click the Original or Copy preview button on the Invoice journal form, Customer invoice is generated and printed to the Docentric Screen print destination. The report is generated using the default Docentric template for the current company (USMF) and the runtime language (language of the customer DE-001, which is en-us). Printing to Screen means opening printed report in Docentric report viewer.
However, there are some advanced settings in Docentric report setup to configure how Docentric template (aka Docentric design) and Docentric viewer will be used for a particular report.
In Docentric report setup click the Settings action pane tab and then the Preview settings button. The Preview settings form is open.
If we turn off the Use both Docentric design and viewer and Use only Docentric viewer checkboxes, then the built-in SSRS report viewer and the original SSRS report design will be used.
If we turn on the Use only Docentric viewer checkbox, the Docentric report viewer and the original SSRS report design will be used.
If we turn on the Use both Docentric design and viewer checkbox, which is set by default, Docentric viewer and the Docentric (default) template will be used. These values apply for all companies. You can manage exceptions for particular companies using the grids on the form.
Let’s return to our case. The question here is, which Docentric template is going to be used for Original or Copy preview. These are the templates assigned to Customer invoice in Docentric report setup.
The answer is – one of the three default templates with SalesInvoice.Report as Template ID.
Pay attention that Template ID can be the same (SalesInvoice.Report) for different Company IDs and Language IDs, which means that the corresponding template files are actually different (see the File name field).
Templates with SalesInvoice.Report as Template ID are the default templates, and one of them will be used for Original and Copy preview, and not the SalesInvoice.Report_DE-001 as it is the case when we use the Use print management button. Which one will be used depends on the current company and the run-time language (i.e. language of the related invoice customer).
In our example this is the second template used for company USMF and all languages but DE (template file SalesInvoice.Report_USMF.docx), since the language of the customer DE-001 is en-us.