Friday, April 30, 2010

How to display From & To Date Range from Query in Dynamics Ax

If you build a report that use range date you will need to show user which date range he choose 
when he view the report, this method print the date range which user selected it just  add it into
your report header and it'll be like that

Date Range: 01/01/2010..10/01/2010

(Date Range) is the the label of the display method



Display str DateRange()
{
    str rangeValue;
    QueryBuildDataSource datasource;
    QueryBuildRange range;
    ;
    datasource =  element.query().dataSourceTable(tableNum(YourDatasourceTable));
    range = datasource.findRange(fieldnum(YourDatasourceTable, YourDateField));
    if(range)
    {
       rangeValue = range.value();
    }
    return rangeValue;
}