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 :
Microsoft Dynamics AX (Archived)

adding > to query range

(0) ShareShare
ReportReport
Posted on by

hi guys,

i have a table called TestTable which contains 2 fields qty1 and qty2 i need to add a queryrange like(where qty1 >= qty2)

 

    query q;
    TestTable test;
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;
    queryrun qr;
    ;


    q = new query();
    queryBuildDataSource = q.addDataSource(tablenum(TestTable),tablestr(TestTable));
    queryBuildRange = queryBuildDataSource.addRange(fieldnum(TestTable,qty1));
    queryBuildRange.value(strfmt('> TestTable.qty2'));
    //queryBuildRange.value('TestTable.qty1 <= TestTable.qty2');
    info(queryBuildRange.toString());
    qr = new queryrun(q);
    while(qr.next())
    {
        test =qr.get(TableNum(TestTable));
        info(strfmt('%1 > %2',int2str(test.qty1),int2str(test.qty2)));
    }

but its not working can anyone help

*This post is locked for comments

I have the same question (0)
  • Toporjinschi Sergiu Profile Picture
    205 on at
    Re: adding > to query range

    hello!!

    this will work 

         queryBuildRange.value(strfmt('(%1.%2 >= %1.%3)',

                                           tableid2name(queryBuildRange.table()),

                                           fieldstr(TestTable,qty2),fieldstr(TestTable,qty1)

                                          );

  • Toporjinschi Sergiu Profile Picture
    205 on at
    Re: Re: adding > to query range

    or 

     queryBuildRange.value(strfmt(' ( TestTable.qty1 >= TestTable.qty2 ) '));

  • Community Member Profile Picture
    on at
    Re: Re: Re: adding > to query range

    Both of your above codes worked :). thanks Toporjinschi

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
AlissonGodoy Profile Picture

AlissonGodoy 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans