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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

using query build range with multi ranges

(0) ShareShare
ReportReport
Posted on by

I have the below X++ code how can I apply the where clause using query build range.

select pionHCMVacationSettlement where pionHCMVacationSettlement.Worker==22565420970 && pionHCMVacationSettlement.posted==NoYes::No;

I try the following but it does not work

queryBuildRange = queryBuildDataSource.addRange(

FieldNum(PionHCMVacationSettlement,Worker));

queryBuildRange.value(strFmt('(%1 == %3) && (%4 == %5)',

fieldStr(PionHCMVacationSettlement, Worker),

queryvalue(22565420970),

fieldStr(PionHCMVacationSettlement, Posted),

queryvalue(NoYes::No)));

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Denis Macchinetti Profile Picture
    16,444 on at

    Hi

    You can do in a more simply way :

    queryBuildRange = queryBuildDataSource.addRange(FieldNum(PionHCMVacationSettlement,Worker));

    queryBuildRange.value( queryvalue(22565420970) );

    queryBuildRange = queryBuildDataSource.addRange(FieldNum(PionHCMVacationSettlement,Posted));

    queryBuildRange.value( queryvalue( NoYes::No ) );

  • maram fraij Profile Picture
    on at

    that means by adding two ranges to the same queryBuildRange  the condition will be adding between the ranges not the second one overwrite the first one ?  

  • mostafa mahmoud Profile Picture
    5,125 on at

    DENIS MACCHINETTI is right , the piece of code he wrote is the correct one ,

    you can also use the SysQueryRangeUtil Class for date ranges and other range scenarios

    for more information use the below link 

    Link

  • Martin Dráb Profile Picture
    237,970 Most Valuable Professional on at

    @Maram: Yes, if you set a value to one range object, it has no effect to other ranges. Nevertheless if you set value again on the same object, the previous value would be lost.

  • Muhammad_Ali Profile Picture
    353 on at

    @Martin in this case "Nevertheless if you set value again on the same object, the previous value would be lost." How do we write two ranges on a same field ?

    For example

    Have a field Invoice on a form. I need to add a range on Invoice to display only the records which does not start with "Inv" AND don't show the records which has Invoice field as empty.

    How can this be achieved if possible?

    Thanks

  • Martin Dráb Profile Picture
    237,970 Most Valuable Professional on at

    Simply call addRange() once more; it will create a new range object.

    For example:

    FieldId fieldId = ...;
    qbds.addRange(fieldId).value("First filter");
    qbds.addRange(fieldId).value("Second filter");
  • Muhammad_Ali Profile Picture
    353 on at

    Thanks Got it !!

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans