This post is machine-translated. The original post in german language can be found here.

Example of a date filter in a form DataSource

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.

public void applyFilter()
{
    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.

These post applies to following versions:
Axapta 2.5, Axapta 3.0, Dynamics AX 4.0, Dynamics AX 2009, Dynamics AX 2012

 
 

 

 
 
 
Posts of the actual month
November 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
252627282930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.