Tuesday, November 17, 2015

Generate Report through code in ax 2012

In this post I am trying to automatically save report to any format in the shared drive.
report is generating based on parameters, after this we can check in the drive that report is stored in the drive.



static void GenerateReportThroughCode(Args _args)
{
    S3_WHSVariantTable        S3_WHSVariantTable;
    InventItemBarcode         inventItemBarcode;
    ReportRun                 reportRun;
    ;
        select inventItemBarcode where inventItemBarcode.itemBarCode == '4015400548485';
        reportRun = new ReportRun(new Args(ReportStr(S3_DP_RetailLabel_BN)));//where S3_DP_RetailLabel_BN is Morphx Report
        reportRun.args().caller();
        //reportRun.args().parm(itemId);
        reportRun.args().record(inventItemBarcode);
        // reportRun.args().object(List);
        //reportRun.printJobSettings().runServer();
        reportRun.printJobSettings().setTarget(PrintMedium::File);
        reportRun.printJobSettings().format(PrintFormat::PDF);
        reportRun.printJobSettings().fileName(strFmt(@"\\SERVERNAME\FolderName\Barcode\%1.pdf",inventItemBarcode.itemId));
        // reportRun.printJobSettings().outputToClient(true);
        // reportRun.printJobSettings().clientPrintJobSettings();
        reportRun.run();
}

No comments:

Post a Comment