Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

RE: SQL awaiting command when running "Sales invoice report" to PDF or Screen

$
0
0

I would like to add additional info:

1. Sales invoice SSRS is customized but only simple like the print layout and adding some field on salesinvoiceDP. I have done similar customization with No Issue.

2. There is customization to print PDF by X++ on web service class.

The PDF generation is using Static Method.

public static fileName  PDFGenerate_SalesInvoice(custinvoicejour _custInvoiceJour, FilePath _filePath)
{
    SalesInvoiceContract            salesInvoiceContract   = new SalesInvoiceContract();
    SrsReportRunController          ssrsController = new SrsReportRunController();
    SRSPrintDestinationSettings     printerSettings;
    FileName                        fileName;

    ;
    if(!_custInvoiceJour.RecId)return fileName;



    //tell the controller the report to run (filename, design name)
    ssrsController.parmReportName(ssrsReportStr(SalesInvoice, Report));
    //define how we want to execute the report (right now or batch style)
    ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    //hide the report dialog
    ssrsController.parmShowDialog(false);

    //we need to populate the required parms for the current sales order controller
    salesInvoiceContract.parmRecordId(_custInvoiceJour.RecId);
    salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
    salesInvoiceContract.parmPrintCopyOriginal(PrintCopyOriginal::Original);

    //link the contract to the controller so we know how to run the dp
    ssrsController.parmReportContract().parmRdpContract(salesInvoiceContract);

    //link the printer settings to the controller
    printerSettings = ssrsController.parmReportContract().parmPrintSettings();
    //print to pdf and always overwrite if the file exists
    printerSettings.printMediumType(SRSPrintMediumType::File);
    printerSettings.fileFormat(SRSReportFileFormat::PDF);
    printerSettings.overwriteFile(true);

    fileName    =  _filePath  + _custInvoiceJour.InvoiceId + "_" + _custInvoiceJour.SalesId + "_" + _custInvoiceJour.InvoiceAccount + ".PDF";

    printerSettings.fileName(filename);

    try
    {
        //run & save the report
        //ssrsController.startOperation();
        ssrsController.runReport() ;//refer to update at top of page
    }
    catch(Exception::Error)
    {

        Warning(strFmt("Error on saving report PDF, make sure SSRS server is valid, %1 / %2" , _custInvoiceJour.SalesId, _custInvoiceJour.InvoiceId));
    }
    return fileName;

}



Viewing all articles
Browse latest Browse all 175888

Trending Articles