Query range not equal to zero

17,690

Do not make it harder:

qbds.addRange(fieldNum(HcmEmployment,LegalEntity)).value(SysQuery::valueNot(0));

The reason for your failed query expression was the use of queryValue("0") which quotes the zero. Changing that to 0 would work as well, but again too laborious.

And even shorter is:

qbds.addRange(fieldNum(HcmEmployment,LegalEntity)).value('!0');

To diagnose query errors take a look on the SQL generated:

info(qbds.toString());
Share:
17,690
RT.
Author by

RT.

Updated on June 08, 2022

Comments

  • RT.
    RT. almost 2 years

    I'm in AX 2012 R2 environment.

    I would like to add a query range to HcmEmployment table and filter out rows that have a LegalEntity value = 0.

    The following code fails at runtime with the exception "Invalid Range".

    qbrLegalEntity = qbds.addRange(fieldNum(HcmEmployment, LegalEntity));
    strRangeCondition = '(%1 != %2)';
    qbrLegalEntity.value(strFmt(strRangeCondition, 
                            fieldStr(HcmEmployment, LegalEntity),
                            queryValue("0")));
    

    Is it possible to code this range condition?

    Thank you.