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)

check query range value: null or specific value (for enum)

(0) ShareShare
ReportReport
Posted on by

Hello,

I have enum value in query (one of the datasource is view, and the field may contain null value or specific value).

How can I check out for querybuildRange, whether the enum is empty or has a specific value?

i.e:

enum value is empty or enum value = 8

QueryBuildRange qbr = 

qbr = this.query().dataSourceNo(1).addRange(fieldNum(MyView, MyField));

qbr.value("null, 8"); // what shall I put here?

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at
    RE: check query range value: null or specific value (for enum)

    I have found solution at:

    msdn.microsoft.com/.../gg845841.aspx,

    (adding computed column - That's real sql column, which can be filtered)

    and add a computed column such as isnull(MyColumn, 0).

    I have checked that column for 0, <value> (I can do other combination that identify a null column, such as isnull(mycolumn, -1))

    At code I did queryBuildRange.value(0, 8);

    That's work fine!!!

    Consider this issue as closed one.

    Thanks, anyway :)

  • Community Member Profile Picture
    on at
    RE: check query range value: null or specific value (for enum)

    What can I do instead?

    1. I made query object with datasources. several of datasources are linked with outerJoin.

    2. The query of step 1 is the base query for new view object.

    3. Because sometimes I need to check whether there is null value on field or whether there is a specific value of field (in sql it was ... where ifnull(myfield, "***") in ('***', 'abc')

    4. When I open the view, I see that null value for recid is represented as 0, but if I put 0 top of grid - I see no records.  the (ATable.AField == AValue) doesn't show value for null columns.

    5. Or may I add computed field on view (If so, than how can I do that)?

    What is the correct syntax?

    I can do two queries, and combine them to one query with 'union', but this is not obvious.

    Thanks :)

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: check query range value: null or specific value (for enum)

    you need to write query OR condition using expression, like this

    queryBuildRange.value(strFmt('((%1.%2 == "%4") || (%1.%3 == "%5"))',

    Please verify if this helps you.

  • Suggested answer
    Martin Dráb Profile Picture
    235,934 Most Valuable Professional on at
    RE: check query range value: null or specific value (for enum)

    Dynamics AX doesn't support nullable primitive types.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Mea_ Profile Picture

Mea_ 4

#3
Rahul Shah Profile Picture

Rahul Shah 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans