Tuesday, 7 November 2017

How to get selected query range value using x++ code in Ax 2012 R3

To get selected query range value

In My case need to get selected query range value from existing query.

Conditions

  1. If  range is applied need to filter based on the range 
  2. If  range not applied default it should take system language


    QueryBuildDataSource    qbdsProductTranslation;
    QueryBuildRange         queryBuildRange;
    QueryFilter             queryFilter;
    QueryRun                queryRun;

    qbdsProductTranslation    = _query.dataSourceTable(tableNum(EcoResProductTranslation));
    queryFilter = _query.findQueryFilter(qbdsProductTranslation, fieldStr(EcoResProductTranslation,      LanguageId));

    if(!queryFilter || !queryFilter.value()) //To handle the situation like If languageId is added to Range set to empty and If LanguageId is not added to Range
    {
        queryBuildRange  = qbdsProductTranslation.addRange(fieldNum(EcoResProductTranslation,LanguageId));
        queryBuildRange.value(SystemParameters::getSystemLanguageId());
        queryRun = new QueryRun(_query);
        _query   = queryRun.query();

    }

//setExecutionIdRangesOCP

No comments:

Post a Comment