Wednesday 16 November 2016

How to save report using x++ code ax 2012

static void generatePDF(Args _args)
{
    SrsReportRunController          projInvoiceController = new SrsReportRunController();
    //ProjInvoiceContract             projInvoiceContract   = new ProjInvoiceContract();
    PSAProjInvoiceContract          projInvoiceContract = new PSAProjInvoiceContract();
    SRSPrintDestinationSettings     settings;
    SrsReportEMailDataContract      emailContract;
    Args                            args = new Args();
    str                             ReportPath;
    ReportPath = 'C:\\ProjectInvoice.pdf';

    select firstOnly projInvoiceJour;
    args.record(projInvoiceJour);

    projInvoiceController.parmReportName(ssrsReportStr(PSAProjInvoice, Report));
    projInvoiceController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    projInvoiceController.parmShowDialog(false);

    projInvoiceContract.parmProjInvoiceJourRecId(projInvoiceJour.RecId);
    projInvoiceContract.parmReportTitle("Invoice");
    projInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
    projInvoiceController.parmArgs(args);

    projInvoiceController.parmReportContract().parmRdpContract(projInvoiceContract);

    // Change print settings as needed
    settings = projInvoiceController.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::PDF);
    settings.overwriteFile(true);
    settings.fileName(ReportPath);

    // Execute the report
    projInvoiceController.runReport();

}

how to send email with attachment using x++ code
https://blogs.msdn.microsoft.com/dynamicsaxbi/2012/03/09/how-to-directing-reports-to-email/ 

No comments:

Post a Comment