AX 2012 Filter by Grid - Using dates

I have a grid who display all records of a table , i want to filter records by two date

how can i produce for that


Thank you

Could you be a bit more specific?


follow the below process,


Go to classdeclaration and declare a queryBuildRange object

public class FormRun extends ObjectRun


QueryBuildRange qbr1,qbr2;



Override the init() method od DATASOURCE - Please note after super() ur range should be defined as your datasource will get initialized after super()

public void init()



qbr1 = this.query().dataSourceNo(1).addRange(fieldnum(tablename, fieldname1));

qbr2 = this.query().dataSourceNo(1).addRange(fieldnum(tablename, fieldname2));



Override the executeQuery() method on datasource - should be before super()

public void executeQuery()



qbr1.value(queryValue(ConfirmedDate.dateValue())); // set control autodeclaration to yes and use control name.datevalue() here

qbr2.value(queryValue(RequestedDate.dateValue())); // set control autodeclaration to yes and use control name.datevalue() here

super(); // will retrive all the records from the table and shows it on the grid



Finally on the control event

Go to date controls >> OverRide the modified method and add the following code after super()

public boolean modified()


boolean ret;

ret = super();


return ret;


Harendra Vepati replied on Fri, Jun 13 2014 6:56

Hi Harendra

first thank you for you replay and is’t work , when i excute form he don’t display all data and when i enter the value of date for filtring he don’t show result of request

datasource has many records inserted.


There is the solution of my issue using SysQuery::range() to specify a range of values:

public void executeQuery()


QueryBuildRange qbrName;

QueryBuildDataSource qbds;

QueryBuildRange qbr;

Range range;


// specify whatever table you need to filter

qbds = this.query().dataSourceTable( tablenum(AALReportTable) );

qbr = qbds.addRange( fieldnum(AALReportTable, DateDebut) );

// suppose fromDate and toDate are declared somewhere

qbr.value( SysQuery::range( dateD.dateValue(), dateF.dateValue()) );