How to filter the data in a report according to from date and to date supplied from front end.

Hi all,

I have made a report which displays nearly 14 fields including the ‘TransDate’ field with “TaxTrans_IN” table as the datasource of that report in AX 4.0.

But now my requirement is to filter the transactions displayed in the report according to ‘Fromdate’ and ‘Todate’ form front end.

Also i have added these 14 fields in the body section instead of programmable section.

I wrote the following code in fetch method for filter the data according to fromdate and todate supplied from front end:-

public boolean fetch()
{
boolean ret;
QueryRun Qry;
Query p = new query();
QueryRun qryRun, qryRunLoc;

QueryBuildDataSource qbds;
QueryBuildRange qbdr;
;

ret = super();
qryRun = new queryRun(this.query());
qryRunLoc = new queryRun(this.query());
qbds = qryRun.query().dataSourceNo(1);
qbdr = qbds.addRange(fieldNum(TaxTrans_IN, TransDate));
qbdr.value(queryRange(fromDate, toDate));
if( fromDate && toDate )
{
qbds.addRange(fieldNum(TaxTrans_IN, TransDate)).value(queryRange(fromDate, toDate));

p.addDataSource(tablenum(TaxTrans_IN)).addRange(fieldnum(TaxTrans_IN, TransDate)).value(strfmt(’"%1…%2’, fromDate, toDate));

}

Qry = new QueryRun(p);
return true;
}

Even after writing the above code it is not filter the data and displying the whole transactions from the beginning.

Kindly let me know where i m wrong and do send any addtional code if required and also explain the meaning of additional code as why we are writing tht code if required as I am a fresher and need to know thought process required to accomplish this task.

Thanks in advance.

Hi Karan,

Do not call super() when you override the fetch method in a report.