How to Use More Than One Template per Report

Default report templates

Each Docentric report can have more than one template assigned, but one group of templates with the same Template ID always acts as so called default templates. When a report runs, a single default template is automatically selected considering the run-time language (usually current user language or, e.g. Customer language) and company (usually current company). Templates can be also company and language neutral.

Thus, if we want to have for the same SSRS Report Design (e.g. SalesInvoice.Report) different Docentric’s templates for different companies and languages at our disposal, no coding is needed. Which (default) template will be automatically selected depends only on the report template setup.

In the above example:

  • If the run-time company is USMF and the run-time language EN-US ->
    the template with Template ID = ‘SalesInvoice.Report’, Company ID = ‘usmf’ and Language ID = ‘en-us’ is used.
  • If the run-time company is USMF and the run-time language DE ->
    the template with Template ID = ‘SalesInvoice.Report’, Company ID = ‘usmf’ and Language ID = ” (language neutral) is used.
  • If the run-time company is JPMF and the run-time language EN-US ->
    the template with Template ID = ‘SalesInvoice.Report’, Company ID = ” (company neutral) and Language ID = ‘en-us’ is used.
  • If the run-time company is JPMF and the run-time language DE ->
    the template with Template ID = ‘SalesInvoice.Report’, Company ID = ” (company neutral) and Language ID = ” (language neutral) is used.

And if we want to change the default behaviour of template selection and to use a non-default template (e.g. SalesInvoice.Report_AlternativeTemplate) instead of the default one, the only way to do this is to switch templates dynamically, i.e. during report execution. Hence we have to create a custom DSP (Data Source Provider) class, and implement the overrideReportRunSettings() method. In this method we can also change the selected print destination and its settings, replace custom placeholders, etc. Learn more >>

Automatic template selection when report runs, among all available and enabled default templates, is done considering the runtime language and company. However, no matter if the template is language neutral or language specific, the use of labels on the template stays the same – there is no technical limitations in this regard. It is entirely up to you how you will organize the templates for a report in terms of languages and, more often, companies.

Let’s say we have different invoices for different customers. With Print Management framework we can set up different Designs of an SSRS report to be used for printing a report when the required conditions are met.

When we use an SSRS report as a Docentric report we actually replace one SSRS Report Design with one Docentric Report. Therefore it is sufficient to have a single template (per company, per language) for each Docentric Print Management report.

However, if the built-in Print Management framework does not allow us to set all conditions we need, we can select the required template dynamically, i.e. in the code:

  • We have to create a custom DSP (Data Source Provider) class using the wizard, if we haven’t already do that (e.g. in order to extend the existing data source with some additional data)
  • Implement the overrideReportRunSettings() method of this class to dynamically select a report template. In this method we can also change the selected print destination and its settings, replace custom placeholders etc.

Learn more >>

Ordinary SSRS reports

On the built-in report dialog form we can select report parameter values as well as a print destination but we cannot select a template. When a report executes one of the default templates is used. We can change this only if we dynamically switch the template in the code.

Thus, we have to create a custom DSP class using the wizard and implement the overrideReportRunSettings() method. Learn how >>

We can also enable selection of a template on the report dialog form by adding Template ID, Company ID and Language ID as Data Member Attributes to a SSRS Report Data Contract. This makes them visible as report parameters on the report dialog form so end users get an option to select a particular template among all other report parameters.

Use the DocSrsReportTemplateId EDT as a data type of the Template ID Data Member Attribute. This Extended Data Type has the FormHelp property set to the DocSrsReportTemplateLookup form, enabling this way use of the custom lookup form that already supports templates filtering by the current report.

Learn more on how to enable selection of a template on the report dialog form >>
Learn more about default report templates >>

Make your own setup extension for a specific report

In both cases (a Print Management report and an ordinary SSRS report) we can make our own setup extension with UI support for the sake of end users.

This means that for a specific report, e.g. Invoice we can introduce an additional setup table that is related to the tables DocReportTable and DocTemplateTable, and also to other tables, e.g. CustTable that play a role in the conditions to select a particular template.

Then in the overrideReportRunSettings() method of the custom DSP class of the Invoice report apply the business logic based on your setup and select the proper report template.

See also

How to Dynamically Switch Selected Template >>
How to Use a Built-in SSRS Report as Docentric Report >>
How to Use a Print Management SSRS report as Docentric Report >>

IN THIS ARTICLE