I need to add a filter to a report in Dynamics AX 2009. Msdn tell me to filter using Fetch event. So i’ve added the following code into the fetch.
DateFromDialog and DateToDialog are variable declared into ClassDeclaration.
qrun = new QueryRun(element);
_vendInvoiceJour = qrun.get(TableNum(VendInvoiceJour));
if( _vendInvoiceJour.InvoiceDate <= DateFromDialog.value() || _vendInvoiceJour.InvoiceDate >=DateToDialog.value() ) {
// Exclude record, don't print it
return false;
}
Is it correct to return false if the record must not printed ?
Thanks
No, it is not. If your your first record is to be excluded, the
fetchmethod return false without sending a single record and nothing is printed.You can return false in the
sendmethod. That works but is a poor choice for performance reasons.The correct way is to add the date range as a query range:
I have not tested the code.