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

Announcements

No record found.

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 636

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 580

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 272 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans