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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

X++ dynamics Queries + How to add AND condition in the same field of a table.

(0) ShareShare
ReportReport
Posted on by 5

I want to add a AND expression as  range to wmsInventLocation field in InventDim table. standard is already constructing a query and i need to add additional piece of range. 

Scenario : There is a custom field YesNo field(CanReserve) in WMSLocation table. and i can toggle this to multiple records. Now to that above stated standard query, which is ideally selecting invendDim table and i want to add not consider these two location.(the two location that i have marked as CanReverve)

standard query is like : {Query  object f60e9670: SELECT WITH SELECT_ORDER SUM(AvailPhysical), SUM(AvailOrdered), SUM(OnOrder) FROM InventSum(InventSum_1) GROUP BY InventSum.ItemId ASC WHERE ((ClosedQty = 0)) AND ((Closed = 0)) AND ((ItemId = N'AK0002')) JOIN * FROM InventDim(InventDim_1) GROUP BY InventDim.InventSiteId ASC, InventDim.InventLocationId ASC, InventDim.wMSLocationId ASC ON InventSum.InventDimId = InventDim.inventDimId AND ((configId = '')) AND ((InventSizeId = '')) AND ((InventColorId = '')) AND ((InventStyleId = '')) AND ((InventSiteId = N'QBR')) AND ((InventLocationId = N'SQS')))}

Now i have added the below piece of code. so i am selection those particular locations and adding as valutNot(<those selected locations>)

pastedimage1595670960763v1.png

but what is happening is, the query is adding those ranges are OR condition.

{Query  object f60e9670: SELECT WITH SELECT_ORDER SUM(AvailPhysical), SUM(AvailOrdered), SUM(OnOrder) FROM InventSum(InventSum_1) GROUP BY InventSum.ItemId ASC WHERE ((ClosedQty = 0)) AND ((Closed = 0)) AND ((ItemId = N'AK0002')) JOIN * FROM InventDim(InventDim_1) GROUP BY InventDim.InventSiteId ASC, InventDim.InventLocationId ASC, InventDim.wMSLocationId ASC ON InventSum.InventDimId = InventDim.inventDimId AND ((configId = '')) AND ((InventSizeId = '')) AND ((InventColorId = '')) AND ((InventStyleId = '')) AND ((InventSiteId = N'QBR')) AND ((InventLocationId = N'SQS')) AND ((NOT (wMSLocationId = N'LOS')) OR (NOT (wMSLocationId = N'PLO')))}
Since it is OR, its only negletting the value LOS, and its considering the quantity from PLO even though its marked as reserve.
So instead of this or, how can i add AND?
I want to have that code looks like 
pastedimage1595671409430v2.png
Can anyone help me on this.
I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    This doc tells you how: docs.microsoft.com/.../using-expressions-in-query-ranges

  • André Arnaud de Calavon Profile Picture
    303,395 Super User 2026 Season 1 on at

    Hi Vivek,

    Can you explain which exact method is executing the standard query and where you need to use your logic?

  • Verified answer
    Blue Wang Profile Picture
    Microsoft Employee on at

    HI Vivek,

    qbr = qbds.addRange(fieldNum(InventDim, WMSLocationID));
    qbr.value(SysQuery::valueNot('A')   ','   SysQuery::valueNot('B'));
    Please refer this thread:community.dynamics.com/.../683380

  • Vivek as Profile Picture
    5 on at

    HI Blue Wang,

    Apologies for late replay.. It worked really. This was the exact scenario that i was looking for.

    Thanks a lot. :)

  • Vivek as Profile Picture
    5 on at

    HI,

    Its post event handler returning me a standard query. and i need to add few ranges into it.

  • Vivek as Profile Picture
    5 on at

    Thanks Nikolaos,

    I wasn't much aware of the rules should be considered while constructing these queries ..

    Thanks for your response. :)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 386

#3
Adis Profile Picture

Adis 259 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans