How to Add New Report Format to Print Management

In this article we will address two possible scenarios when you need to add an additional report format (aka SSRS report design) to Print management for an existing Document type.

For example, let’s say that we’ve created two new SSRS report designs for the Sales invoice report (aka the Customer invoice print management document type): DocSalesInvoice.Report and DocSalesInvoiceExt.Report, and now we want them to appear in Print management setup.

The additional requirement is that DocSalesInvoice.Report should be the default report design – the one which is used when previewing report from the Invoice journal form (Original/Copy preview).

In one of the next articles, we will explain how to create a new custom Print management Document type and add it to Print management setup (for example, Vendor reminder letter), but this is a completely different topic.

Print management setup: Add new report format

To achieve adding two new SSRS report designs DocSalesInvoice.Report and DocSalesInvoiceExt.Report to Print management setup for the Customer invoice document type, the following extension should be created:

Keep in mind that there is no guarantee in which order class method extensions will be executed, so you will need to check first if the format with the same name is already added, which can happen if you need to combine this extension with the Default report format extension (please see the next chapter).

How it works

When Print management setup is open (and in some other situations), the PrintMgmtReportFormatPopulator.addDocuments() method is invoked, which will execute our code and add our two new Sales invoice report designs. In fact, the below class extension method placed in the Application Suite model will be executed.

Eventually, 2 new records are added to the PrintMgmtReportFormat table.

Note that if we delete all records from the PrintMgmtReportFormat table, the table will be repopulated the next time when Print management setup is open.

Original/Copy preview: Change default report format

If you need to change the default report format, which is used for Original/Copy preview on journal forms, Microsoft recommendation is to use the Default report format delegate: PrintMgmtDocType.getDefaultReportFormatDelegate().

For example, our event handler for this delegate can look like this.

How it works

PrintMgmtDocType.getDefaultReportFormat() is a method that raises the event based on the Default report format delegate - PrintMgmtDocType.getDefaultReportFormatDelegate(). This method is invoked from all report controllers for Print management reports when performing Original/Copy preview.

At the same time, when the PrintMgtmReportFormat table, which is used in Print management setup when selecting Report format, gets populated as described previously, this very event PrintMgmtDocType.getDefaultReportFormatDelegate() is also raised, so our new default report format will be added to the PrintMgmtReportFormat table automatically.

To change the default report format used for Original/Copy preview, you need to implement an event handler for PrintMgmtDocType.getDefaultReportFormatDelegate(). The new default report format will be added to PrintMgmtReportFormat table and appear in Print management setup automatically.

Concerns

We are not sure if the approach with the Default report format event handler is 100% reliable since it seems that it might cause unexpected results regarding:

  • which SSRS report design will actually be configured as the default report format, and
  • populating the PrintMgtmReportFormat table used in Print management setup for selecting Report format. Namely, it might happen that some of the adding reports will not be included in this table and consequently not appear in Print management setup.

Let’s take a closer look.

Concern #1: Which report will be default?

You probably won’t have multiple event handlers for the Default report format delegate for the same Print management document type, but what if there are already such handlers in the system? For example, there is a class in the Application Suite model (PrintMgmtDocTypeEventHandler_IT), which might change the default report format for Sales invoice. Who guaranties that our subscriber method will be executed the last in the CoC chain?

As if this is not interesting enough, there is another built-in event handler PrintMgmtDelegatesHandler::getDefaultReportFormatDelegateHandler() that blocks all other subscribers after the first one is executed, and if there is no subscribers for changing the default format for the executing document type at all, the one provided by the system will be used (through the PrintMgmtDelegatesHandler::getDefaultReportFormat() method); for Sales invoice that would be, e.g. SalesInvoice.Report.

When implementing the Default report format event handler for a Print management document type, you need to check if there are other subscribers for this document type, and if so, to consolidate them - there can be only one subscriber – to avoid unreliable results.

Concern #2: How to populate Print management setup properly?

Each time Print management setup is open, the PrintMgmtReportFormat table gets re-populated. If the record with SalesInvoice.Report is missing, it will never be added again because it is not the default report format anymore - we changed this via our subscriber method to the Default report format delegate. And what if we wanted to keep it, just not having it as the default one?

We can solve this by changing the addDocuments() method from the previous chapter:

Country-region specific SSRS report designs

The special caution is needed when dealing with country-region specific SSRS report designs. You can add such report design only by extending the PrintMgmtReportFormatPopulator.addDocument() method, because the Default report format event handler doesn’t support including of country-region information.

Populating the PrintMgtmReportFormat table is country-region specific. When adding a new report to the PrintMgmtReportFormat table via the Default report format event handler, you cannot control the country-region field, but you can fix it via CoC of the PrintMgmtReportFormatPopulator.addDocument() method if needed.

Good luck with Print management customization!

4 thoughts on “How to Add New Report Format to Print Management

  1. I couldn’t find any follow up article with regards to this section of this blog

    “In one of the next articles, we will explain how to create a new custom Print management Document type and add it to Print management setup (for example, Vendor reminder letter), but this is a completely different topic.”

    Please point me in the right direction

    1. Hi Lisa,

      Thank you for your comment. I’m sorry, but as of now, the article mentioned here hasn’t been written yet. I checked with our team, and they said they have it in the pipeline but can’t give any dates for it right now.

      For now, please stay tuned! The best way to be notified of news, including new articles, is to subscribe to our blog.

      Best regards,
      Jure

        1. I’m sorry Lisa, but the answer is no ☹.

          This probably will never become a functionality of the core product. We will just demonstrate on a real-world example how to create a custom Print management document type. However, during this research, we will better understand if we can create some Code generator / Wizard / VS Add-On for creating a custom Print management document type. I’m sorry we couldn’t help more right now.

          Kind regards,
          Ana

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>