web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Query range expressions in AX

(0) ShareShare
ReportReport
Posted on by 640

Hi Experts,

Can anyone help me to spot the mistake in the below query range expression. I need to filter the records with transtype == payment & Last settlevoucher  is empty. 

public void init()
{
QueryBuildDataSource qbds;
QueryBuildRange qbr;

super();

qbds = this.query().dataSourceTable(tableNum(VendTrans));


qbr = qbds.addRange(fieldNum(VendTrans,LastSettleVoucher));
qbr = qbds.addRange(fieldNum(VendTrans,TransType));

qbr.value(strFmt('((LastSettleVoucher == "%1") && (TransType == %2))',
queryValue(""),
queryValue(any2int(LedgerTransType::Payment))));

qbr.status(RangeStatus::Hidden);
}

pastedimage1658405798876v1.png

I have the same question (0)
  • Verified answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    You don't need to get value with %1 for empty string. As a matter of fact, there is no need for you to use Expressions. If you give range values to the fields like below, such errors will not occur.

    Expressions are mostly used to write "or" clauses between multiple fields and create more complex structures.

    QueryBuildDataSource qbds;
        QueryBuildRange qbrSettle,qbrTransType;
        super();
    
        qbds = this.query().dataSourceTable(tableNum(VendTrans));
    
        qbrSettle = qbds.addRange(fieldNum(VendTrans,LastSettleVoucher));
        qbrSettle.value(SysQuery::valueEmptyString());
        
        qbrTransType = qbds.addRange(fieldNum(VendTrans,TransType));
        qbrTransType.value(sysquery::value(LedgerTransType::Payment));

  • Rohit P Modani Profile Picture
    15 on at

    Hi,

    You can try the solution mentioned by Ergun or try the below snippet.

    Just remove the "" from %1.

    qbr = qbds.addRange(fieldNum(VendTrans,LastSettleVoucher));
    qbr = qbds.addRange(fieldNum(VendTrans,TransType));
    qbr.value(strFmt('((LastSettleVoucher == %1) && (TransType == %2))',
    queryValue(""),
    queryValue(any2int(LedgerTransType::Payment))));

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 426 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 371

#3
Martin Dráb Profile Picture

Martin Dráb 279 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans