Wednesday, November 16, 2022

SalesInvoice change file name when using print management with File DocumentType

/// <summary>
///     To handle the report design to print based on caller
/// </summary>
[ExtensionOf(classStr(SalesInvoiceController))]
final class SalesInvoiceController_MY_Extension
{
    /// <summary>
    ///     choose report design
    /// </summary>
    protected void outputReport()
    {
        Args controllerArgs = this.parmArgs();
        SRSCatalogItemName  reportDesign;
        if((controllerArgs.menuItemName() == menuItemOutputStr(SalesInvoice_CUSTOM)) || custInvoiceJour.isProforma() || (controllerArgs.menuItemName() == menuItemOutputStr(SalesInvoice)))
        {            
            reportDesign = ssrsReportStr(SalesInvoice_Custom,Report_Custom);
        }
        else 
        {
            reportDesign = ssrsReportStr(SalesInvoice_Custom,Report);
        }
        this.parmReportName(reportDesign);
        this.parmReportContract().parmReportName(reportDesign);

        SRSPrintDestinationSettings srsPrintDestinationSettings = formLetterReport.getCurrentPrintSetting().parmPrintJobSettings();
        SRSPrintMediumType srsPrintMediumType = srsPrintDestinationSettings.printMediumType();
        formletterReport.parmReportRun().settingDetail().parmReportFormatName(reportDesign);

        if (srsPrintDestinationSettings.printMediumType() == SRSPrintMediumType::File)
        {
            srsPrintDestinationSettings.fileName(custInvoiceJour.InvoiceId);
        }
        srsPrintDestinationSettings.overwriteFile(true);

        next outputReport();
    }

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8