Filter the form by date


I want to filter a form by dates, fromDate and and toDate, i have also been reading about init and executequery methods,can anyone give me an example of how init and executequery works or a form path in Ax that utilize the methods so i can follow the example.

You must add a range to the query and set its value.

For example, you can add the range in executeQuery() like this:

QueryBuildRange dateRange = SysQuery::findOrCreateRange(this.queryBuildDataSource(), fieldNum(MyTable, MyDateField));

This code either creates a new range, or it uses an existing one, if it exists.

Then you must set a value based on your dates. It might look like this:

dateRange.value(SysQuery::range(FromDate.dateValue(), ToDate.dateValue()));

Details depends on your particular situation.