Print Report in Microsoft Dynamics AX 2009 through X++

Posted by haroonattari on Stack Overflow See other posts from Stack Overflow or by haroonattari
Published on 2010-10-01T15:11:06Z Indexed on 2011/11/13 9:51 UTC
Read the original article Hit count: 954

Filed under:
|

I am trying to print sales confirmation report on a button click which I have added on Sales Order Detail form in Microsoft Dynamics AX 2009. On click event of that button, I have written following code:

void clicked()
{
    Args                args;
    ReportRun           reportRun;
    SalesFormLetter     salesFormLetter;
    PrintJobSettings    printJobSettings;
    CustConfirmJour     custConfirmJour;
    RecordSortedList    list                = new RecordSortedList(55);
    SalesTable          salesTableUpdate;
    ;

    SELECT firstonly custConfirmJour order by ConfirmID desc where custConfirmJour.SalesId == salesTable.SalesId ;

    list.ins(custConfirmJour);

    args = new Args(ReportStr(SalesConfirm));


    printJobSettings = new PrintJobSettings();
    printJobSettings.SetTarget(PrintMedium::Printer);
    printJobSettings.suppressScalingMessage(true);

    salesFormLetter  = new SalesFormLetter_Confirm(true);
    salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());

    args.designName("Standard");
    args.caller(salesFormletter);
    args.parmEnum(PrintCopyOriginal::Original);
    args.parmEnumType(enumnum(PrintCopyOriginal));
    args.object(list);

    reportRun = new ReportRun(args);
    reportRun.setTarget(PrintMedium::Printer);
    reportRun.init();
    reportRun.run();
}

The code is running fine except on problem that instead of sending the report directly on printer, print preview is coming.

I will be very greateful if anyone of you could let me know what is wrong with this code.

Rgds

Haroon

© Stack Overflow or respective owner

Related posts about axapta

Related posts about x++