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)

select where something equals to (If null then All)

(0) ShareShare
ReportReport
Posted on by 3,371

Hi,

I am building a simple "while select" query which filters on an optional field, if the optional field is not set then the filter should be bypassed.

Is there a way to do this in x++,

If i should go with query builder than just mention that.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    236,505 Most Valuable Professional on at
    RE: select where something equals to (If null then All)

    You want to select records where the field either has the given value, or the default value.

    For example, if it's a string field, your condition will look like WHERE myTable.Field1 == 'abcd' || myTable.Field1 == ''.

  • Hichem.Chekebkeb Profile Picture
    3,371 on at
    RE: select where something equals to (If null then All)

    Sorry Matrin, I think I didn't make my self well understandable,

    The thing is that, my filter value is the optional one not the value in table I am searching in (which is all filled and mandatory).

  • Verified answer
    Martin Dráb Profile Picture
    236,505 Most Valuable Professional on at
    RE: select where something equals to (If null then All)

    Do you mean that you currently add a range even if the filter value is empty? For example, you filter by an empty string instead of not filtering at all?

    I prefer doing such things with the query framework, where you can easily use the IF statement to skip adding the range if you don't want it, or set the range value to SysQuery::valueUnlimited().

    If you meant something else again, please give us a concrete example.

  • Hichem.Chekebkeb Profile Picture
    3,371 on at
    RE: select where something equals to (If null then All)

    Yes, this is what I ended up doing.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans