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 :
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

  • Suggested answer
    Martin Dráb Profile Picture
    241,656 Most Valuable Professional on at

    Dynamics AX doesn't support nullable primitive types.

  • Suggested answer
    Community Member Profile Picture
    on at

    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.

  • Community Member Profile Picture
    on at

    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 :)

  • Verified answer
    Community Member Profile Picture
    on at

    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 :)

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
nmaenpaa Profile Picture

nmaenpaa 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans