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)

How to query all in the ENUM type NoYes?

(0) ShareShare
ReportReport
Posted on by 3,732

Hi,

I'm working on the querying values from the table. My task is to query all the values from the NoYes "ENUM" type field. I'm able to query the field which contains only "Yes" and which contains "No".

My requirement is to take all the data in the field, either is it Yes or No. 

Yet now I'm trying this code:

qbrProjStatus = this.query().dataSourceName("AR_VC_SOPMaster").addRange(fieldnum(AR_VC_SOPMaster, Active));
qbrProjStatus.value(Global::queryValue(NoYes::Yes));

OR

qbrProjStatus = this.query().dataSourceName("AR_VC_SOPMaster").addRange(fieldnum(AR_VC_SOPMaster, Active));
qbrProjStatus.value(Global::queryValue(NoYes::Yes));

My requirement is to retrieve all the information from the field either is it Yes or No. I'm doing this task on the FORM level, these details will display on the GRID. I'm using Ax 2009. 

Please suggest me some code too.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Sathish Sivakumar Profile Picture
    3,732 on at
    RE: How to query all in the ENUM type NoYes?

    Hi Guys,

    I hardly tried for 2 days nothing didn't work. At last I found this "SysQuery::valueUnlimited()". This takes all the values either checked or no checked.

  • Suggested answer
    syed baber Profile Picture
    11,633 on at
    RE: How to query all in the ENUM type NoYes?

    Hi Sathish,

    If you want to retrieve all the values from your table based on the active field is set to Yes or No, then you have to used expression in query ranges. Take a look at below links on how to use expression in query ranges:

    www.axaptapedia.com/Expressions_in_query_ranges

    msdn.microsoft.com/.../aa893981.aspx

    Based on your requirements, your code should look like this:

    Query q = new Query();  // Create a new query.

       QueryRun qr;

       QueryBuildDataSource qbr1;

       // Add a single datasource.

       qbr1 = q.addDataSource(tablenum(AR_VC_SOPMaster));

       // Name the datasource .

       qbr1.name("AR_VC_SOPMaster");

       // Add the range to the query data source.

       qbr1.addRange(fieldNum(AR_VC_SOPMaster, Active)).value(

       strFmt('((%1.%2 == NoYes::Yes) || (%1.%2 == NoYes::No))',

           qbr1.name(),        

           fieldStr(AR_VC_SOPMaster, Active)));

    Please let me know if you have further queries.

    Thanks,

    Baber.

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at
    RE: How to query all in the ENUM type NoYes?

    Hi Sathish,

    From your requirement you don't actually need to use this field "Active" into your query range as you need all records irrespective of YES or NO. Just remove your addRange from your datasource it should give you required result.

    However, If any case you still want to use OR condition in your query ranges. You can have a look on this blog article, I am pasting code here for your reference. daxture.blogspot.com.au/.../aot-and-x-queries-and-ranges-in-ax-2012.html

    Adding OR and AND in query

    QueryBuildRange                 qbr;

    qbr = query.dataSourceTable(tableNum(Table)).addRange(fieldNum(Table, Active));

    qbr.value(strFmt('((%1 == %2) || (%1 == %3))',

                         fieldStr(Table, Active),

                         queryvalue(NoYes::YES),

                         queryvalue(NoYes::NO)

                         ));

  • Suggested answer
    Thomas Vogt Poulsen Profile Picture
    345 on at
    RE: How to query all in the ENUM type NoYes?

    As Abhishek_mishra wrote when you could just remove the query range, or if that is not possible do this:

    qbrProjStatus = this.query().dataSourceName("AR_VC_SOPMaster").addRange(fieldnum(AR_VC_SOPMaster, Active));

    qbrProjStatus.value(SysQuery::valueEmptyString());

    That should set the range to accept all values of the Active field.

  • Suggested answer
    Abhishek_mishra Profile Picture
    405 on at
    RE: How to query all in the ENUM type NoYes?

    Why are you adding range on Active field when you don,t want to filter them based on no/yes.

    Remove the code you have provided in your question.:)

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
Community Member Profile Picture

Community Member 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans