Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

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

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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
    Martin Dráb 230,503 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans