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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))] public final class PrintMgmtReportFormatPopulator_WE_Extension { #PrintMgmtSetup protected void addDocuments() { // Add new customized reports this.addOther(PrintMgmtDocumentType::SalesOrderInvoice, ssrsReportStr(DocSalesInvoice, Report), ssrsReportStr(DocSalesInvoice, Report), #NoCountryRegionId); this.addOther(PrintMgmtDocumentType::SalesOrderInvoice, ssrsReportStr(DocSalesInvoiceExt, Report), ssrsReportStr(DocSalesInvoiceExt, Report), #NoCountryRegionId); next addDocuments(); } } |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))] public final class PrintMgmtReportFormatPopulatorAppSuite_Extension { #ISOCountryRegionCodes #PrintMgmtSetup #RusReportFormats protected void addDocuments() { // Purchasing documents this.addPurchaseDocuments(); // Sales documents this.addSalesDocuments(); // Inventory documents this.addInventoryDocuments(); // Project documents this.addProjectDocuments(); // Add the WHS reports. this.addWarehouseDocuments(); // Add the TMS reports. this.addTransportationDocuments(); this.addLocalizationDocuments(); next addDocuments(); } ... } |
Eventually, 2 new records are added to the PrintMgmtReportFormat table.
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.
1 2 3 4 5 6 7 8 9 10 |
[SubscribesTo(classStr(PrintMgmtDocType), delegateStr(PrintMgmtDocType, getDefaultReportFormatDelegate))] public static void PrintMgmtDocType_getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result) { switch (_docType) { case PrintMgmtDocumentType::SalesOrderInvoice: _result.result(ssrsReportStr(DocSalesInvoice, Report)); break; } } |
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.
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.
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))] public final class PrintMgmtReportFormatPopulator_WE_Extension { #PrintMgmtSetup protected void addDocuments() { // Add new customized reports this.addOther(PrintMgmtDocumentType::SalesOrderInvoice, ssrsReportStr(DocSalesInvoice, Report), ssrsReportStr(DocSalesInvoice, Report), #NoCountryRegionId); this.addOther(PrintMgmtDocumentType::SalesOrderInvoice, ssrsReportStr(DocSalesInvoiceExt, Report), ssrsReportStr(DocSalesInvoiceExt, Report), #NoCountryRegionId); // Add the standard report design, because of PrintMgmtDocType.getDefaultReportFormatDelegate() this.addOther(PrintMgmtDocumentType::SalesOrderInvoice, ssrsReportStr(SalesInvoice, Report), ssrsReportStr(SalesInvoice, Report), #NoCountryRegionId); next addDocuments(); } } |
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.
Good luck with Print management customization!
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
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
Thanks Jure, does the functionality already exist and if is there anyone who can walk me through it at all?
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