Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

adding > to query range

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

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

    Both of your above codes worked :). thanks Toporjinschi

  • Re: Re: adding > to query range

    or 

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

  • 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)

                                          );

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans