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, ...
Suggested Answer

How to query amount "greater than" in contract class

(0) ShareShare
ReportReport
Posted on by 596

Hello all,

I have some difficulties during queryBuilder in my contract class. Here are my steps :

1. Create the query using QueryBuilder

qbds = query.addDataSource(tableNum(CaseDetailBase));

qbds1 = qbds.addDataSource(tableNum(CaseCategoryHierarchyDetail));

qbds1.addLink(fieldNum(CaseDetailBase,CategoryRecId ), fieldNum(CaseCategoryHierarchyDetail, RecId));

qbds1.joinMode(JoinMode::InnerJoin);

  

2. Adding some range

qbr = qbds1.addRange(fieldNum(CaseCategoryHierarchyDetail, CaseCategory));

qbr.value(parmCaseCategory);  // parmCaseCategory getting from dialog

qbr2 = qbds.addRange(fieldNum(CaseDetailBase, MYTransactionAmt));  // custom field

qbr2.value(strFmt(">= %1", queryValue(parmPaymentAmount))); // parmPaymentAmount getting from Dialog

The first range was ok, but the 2nd range cannot be added to the range. Something wrong with the code ?

Please help

Thanks,

V

I have the same question (0)
  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Voltes,

    Yes, your code has wrong, In this code, you should use single quotes '' not "".

    qbr2.value(strFmt(">= %1", queryValue(parmPaymentAmount)));

    Please read this:http://www.axaptapedia.com/Expressions_in_query_ranges

    The entire expression must be enclosed within single-quotes, not double-quotes.

  • Voltes Profile Picture
    596 on at

    Hi Blue,

    But my query does not involved dates. it's amount :)

    However I found in your link there is something wrong in my code, inside the Strfmt it should stated again the field name, and I changed to single quote like u suggested.

    In debug, the QBR2 populated now, but somehow it does not recognize the " >= ", it is stated to be "MyTransactionAmt = 0" while even the parmPaymentAmount is grab correctly in this class meaning I have value, but in the query range it shows 0, with the wrong "equal" sign.

    Anything's wrong ?

    Thanks

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,097 on at

    Hi Voltes,

    Instead of using strfmt, I suggest using standard method SysQuery::Range

    qbr2.value(SysQuery::Range(0, parmPaymentAmount));

    of you can continue using strfmt, but you need to use 2 dots:

    qbr2.value(strFmt("..%1", queryValue(parmPaymentAmount)));

  • Voltes Profile Picture
    596 on at

    Hi,

    any reason why I cannot use StrFmt ?

    because many blogs using that, just curios.

    Thanks,

  • Sergei Minozhenko Profile Picture
    23,097 on at

    Hi Voltes,

    No reasons, you can use it, but you need to use correct syntax for greater or equal (FromValue..Tovalue)

    Range function already makes all needed transformations to get a correct string value for ranges and in case if something will be changed in filtering syntax you don't need to care about your customizations.

  • Voltes Profile Picture
    596 on at

    Btw, I found the problem. It turns out with Strfmt, we need to put bracket.

    So it;s like : qbr2.value(strFmt("(TransactionAmt >= %1)", queryValue(parmPaymentAmount)));

    But noted what u suggested, Sergei.

    Thanks

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... 396 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 323

#3
Martin Dráb Profile Picture

Martin Dráb 243 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans