web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Voltes Profile Picture
    596 on at
    RE: How to query amount "greater than" in contract class

    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

  • Sergei Minozhenko Profile Picture
    23,093 on at
    RE: How to query amount "greater than" in contract class

    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
    RE: How to query amount "greater than" in contract class

    Hi,

    any reason why I cannot use StrFmt ?

    because many blogs using that, just curios.

    Thanks,

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at
    RE: How to query amount "greater than" in contract class

    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
    RE: How to query amount "greater than" in contract class

    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

  • Blue Wang Profile Picture
    on at
    RE: How to query amount "greater than" in contract class

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 814 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 798 Super User 2025 Season 2

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 622

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans