Execute report by code and filter values AX 2009

1k views Asked by At

I Need execute CustAccountStatementExt report by code in AX 2009, but I need execute this report by some filter for example CustAccount field of CustTable.

Create a Job to do this, the report execute OK, but without CustAccount filter or any other filter.

Code:

static void SavePdfFileCustAccountExt(Args _args)
{

    Args               args;
    ReportRun          report;
    CustTable          recCustTable;

    ;

    args         = new Args(reportstr("CustAccountStatementExt"));
    recCustTable = CustTable::find("C000000003");

    args.record(recCustTable);

    report = new ReportRun(args);
    report.setTarget(PrintMedium::Screen);

    report.init();
    report.run();
}

Then write this lines but nothing happend.

args.lookupRecord(recCustTable);
args.lookupField(fieldNum(CustTable, AccountNum));
args.lookupValue(recCustTable.AccountNum);

I'm sure I have an error in the code, but I can't find it.

Any Suggestions?

Thanks in advance!

1

There are 1 answers

1
SShaheen On BEST ANSWER

There needs to be code in the init() method of the report that gets the record from args and sets the filters.