how to get static range in your report

2019-08-21 16:29发布

In AX Report the User can select different Range. I seek to show that the criteria used to filter user in the report itself even

the expression "parameter!CustomerAccount.Value" don't work because this filter is not a static parameter.

the user can use any table from the query and any field from the table and any criteria.. I'm locking for trick to get for which table, which field and what criteria it uses.

enter image description here

1条回答
做自己的国王
2楼-- · 2019-08-21 17:21

this method work very well ^_^

(( I use it privet and not static ))

    static void getQueryRanges2(Args _args)
{
 Query query;
 QueryRun queryRun;
 QueryBuildDataSource qbd;
 QueryBuildRange range;
 QueryFilter filter;
 int cnt, filtercnt, i,j, k;
 DictTable dictTable;
 DictField dictField;
 str fieldLabel;
 ;
 query = new query(queryStr(smmSalesCustItemStatistics));
 queryRun = new QueryRun(query);
 queryRun.prompt();
 query = queryRun.query();  for(i = 1; i <= query.dataSourceCount(); i++)
 {
    cnt = query.dataSourceNo(i).rangeCount();
    filtercnt = 0;
    if(!query.dataSourceNo(i).embedded())
    {
        filtercnt = query.queryFilterCount(query.dataSourceNo(i));
    }
    dictTable = new DictTable(query.dataSourceNo(i).table());
    for (k=1; k<= filtercnt; k++)
    {
        filter = query.queryFilter(k, query.dataSourceNo(i));
        dictField = new DictField(query.dataSourceNo(i).table(), fieldname2id(query.dataSourceNo(i).table(), filter.field()));
        info (strFmt("%1, %2. Range = %3", dictTable.label(), dictField.label(), filter.value()));
    }
    for (j=1; j<=cnt; j++)
    {
        range = queryRun.query().dataSourceNo(i).range(j);
        dictField = new DictField(query.dataSourceNo(i).table(), fieldname2id( query.dataSourceNo(i).table(), range.AOTname()));
        if(range.value())
        {
            info(strfmt("%1, %2. Range = %3",dictTable.label(), dictField.label(), range.value()));
        }
    }
 }
}

enjoy :)

查看更多
登录 后发表回答