Add/overwrite SSRS print management design

Add/overwrite SSRS print management design

/// <summary>
/// An extension class of the <c>PrintMgmtReportFormatPopulator</c> class.
/// </summary>
[ExtensionOf(classStr(PrintMgmtReportFormatPopulator))]
public final class VKPrintMgmtReportFormatPopulatorCls_Extension
{
    #PrintMgmtSetup

    /// <summary>
    /// Add custom reports to the print management.
    /// </summary>
    protected void addDocuments()
    {
        this.addOther(PrintMgmtDocumentType::SalesOrderConfirmation, ssrsReportStr(VKSalesConfirm, Report), ssrsReportStr(VKSalesConfirm, Report), #NoCountryRegionId);
        this.addOther(PrintMgmtDocumentType::SalesOrderInvoice, ssrsReportStr(VKSalesInvoice, Report), ssrsReportStr(VKSalesInvoice, Report), #NoCountryRegionId);

        next addDocuments();
    }

}
addOther vs addStandard.
addOther - if populate (PrintMgmtReportFormat::populate()) is executed with standard code, it add a record to the PrintMgmtReportFormat table where System = Yes. Then, if populate is executed with extended code, a new record is added, and it will get System = Yes.
If the population with extended code is executed in the company without prior execution with standard code, only one record is added to the PrintMgmtReportFormat table and it will NOT be System. The report will fail when executed as "Original preview" with error:
  • Report name in report contract cannot be null or empty.
  • Customer CustNum, Invoice InvoiceNum was not delivered because of a print management setup issue. Verify that print management is set up correctly and the destination is valid.

/// <summary>
/// event handler class to print new purchase order report
/// </summary>
internal final class VKPrintMgmtDocTypeCls_EventHandler
{
    /// <summary>
    /// Get new custom default report for purchase order
    /// </summary>
    /// <param name = "_docType">Print mgmt document type</param>
    /// <param name = "_result">delegate for default report</param>
    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
    public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
    {
        switch (_docType)
        {
            case PrintMgmtDocumentType::PurchaseOrderRequisition:
                _result.result(ssrsReportStr(VKPurchPurchaseOrder, Report));
                break;

            case PrintMgmtDocumentType::SalesOrderConfirmation:
                _result.result(ssrsReportStr(VKSalesConfirm, Report));
                break;

            case PrintMgmtDocumentType::SalesOrderInvoice:
                _result.result(ssrsReportStr(VKSalesInvoice, Report));
                break;
        }
    }

}
New print management node
/// <summary>
/// Extension of PrintMgmtNode_Sales class
/// </summary>
[ExtensionOf(classStr(PrintMgmtNode_Sales))]
final class VKPrintMgmtNode_Sales_Extension
{
     /// <summary>
    /// Adds additional document types for Sales module
    /// </summary>
    /// <returns>Document types list</returns>
    public List getDocumentTypes()
    {
        List docTypes;
        docTypes = new List(Types::Enum);
        docTypes = next getDocumentTypes();
        docTypes.addEnd(PrintMgmtDocumentType::VKCustomerReturnReceived);
        return docTypes;
    }

}



Support The Author

 If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.

Buy Me a Coffee

Post a Comment


All Comments


No comments. Be the first one to comment on this post.

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics 365 FO.

Authors are allowed to set their own "buy me a coffee" link.
Join us.

Blog Tags