This post is machine-translated. The original post in german language can be found here.
These post applies to following versions:
Axapta 2.5, Axapta 3.0, Dynamics AX 4.0, Dynamics AX 2009, Dynamics AX 2012
Axapta 2.5, Axapta 3.0, Dynamics AX 4.0, Dynamics AX 2009, Dynamics AX 2012
|
|
|
|
|
|
The following code is an example of how to build a query range based on a Form Data Source, which displays only "daily" records.
In the example the form-dataSource is named DataSourceName and it contains two date fields called FromDate and ToDate. Depending on a check box only records should be displayed, which that are valid for todays date.
{
queryBuildRange qbr;
qbr = sysQuery::findOrCreateRange(DataSourceName_ds.queryBuildDataSource(), fieldNum(DataSourceName, recId));
if( !ShowExpiredCheckBox.checked())
{
qbr.value(strfmt('('+
'((%5.%2 <= %1) && (%5.%3 >= %1)) || ' +
'((%5.%2 == %4) && (%5.%3 == %4)) || ' +
'((%5.%2 <= %1) && (%5.%3 == %4)) || ' +
'((%5.%3 >= %1) && (%5.%2 == %4)) ' +
')',
Date2StrXpp(systemDateGet()),
fieldstr(DataSourceName, FromDate),
fieldstr(DataSourceName, ToDate),
Date2StrXpp(dateNull()),
tableId2name(tableNum(DataSourceName))));
}
else
{
qbr.value(SysQuery::valueUnlimited());
}
}
The above method can be called for example in the executeQuery() of the DataSource.