Skip to main content

Notifications

Announcements

No record found.

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.
  • Vivek as Profile Picture
    5 on at
    RE: X++ dynamics Queries + How to add AND condition in the same field of a table.

    Thanks Nikolaos,

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

    Thanks for your response. :)

  • Vivek as Profile Picture
    5 on at
    RE: X++ dynamics Queries + How to add AND condition in the same field of a table.

    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
    RE: X++ dynamics Queries + How to add AND condition in the same field of a table.

    HI Blue Wang,

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

    Thanks a lot. :)

  • Verified answer
    Blue Wang Profile Picture
    on at
    RE: X++ dynamics Queries + How to add AND condition in the same field of a table.

    HI Vivek,

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

  • André Arnaud de Calavon Profile Picture
    293,027 Super User 2025 Season 1 on at
    RE: X++ dynamics Queries + How to add AND condition in the same field of a table.

    Hi Vivek,

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

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: X++ dynamics Queries + How to add AND condition in the same field of a table.

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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,027 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,852 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans