web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to use enum condition in select query

(0) ShareShare
ReportReport
Posted on by

hi ,

 

In my form i have declare two tables which contains same enum type filed i want to use this field in select query  in where condition to compare the same value

 

pls help

 

 

*This post is locked for comments

I have the same question (0)
  • Amir Nazim Profile Picture
    5,994 on at

    Hi,

    I am not sure i understand it completely but it is very simple, see sample selects,

    if you want to select on any specific enum value

    select firstonly yourTable1 where yourTable1.yourEnumField = YourEnum::Value;

    if you want to select based on your other table then you have to maintain a jon between the two.

    select yourTable1 join yourTable2

    where yourTable1.yourEnumField == yourTable2.yourEnumField;

    or iterate on first table with while loop to pass the enum value to second table select.

    Thanks

    Amir

    https://msdax.wordpress.com

  • Community Member Profile Picture
    on at

    i tried using

    select yourTable1 join yourTable2

    where yourTable1.yourEnumField == yourTable2.yourEnumField

    but getting error operand type not compactible

  • Amir Nazim Profile Picture
    5,994 on at

    this error happen when you dont have the same base type on fields. check the EnumType or EDT property on field. it should needs to be same

  • Community Member Profile Picture
    on at

    You are correct it is not same now how to tackle this scenario i want to use this in select query where clause only to match the transaction type any other suggestion pls provide

  • Amir Nazim Profile Picture
    5,994 on at

    My first question is why you have different enum or EDT while you have similar data in tables ?

    other approach would be not my personal but you can use that. you have to create the mapping of enum values suppose you have below structure of table

    table1, field1, enum1 with values (Eval1,Eval2)
    table2, field1, enum2 with values (Eval3,Eval4)

    u have to create the mapping method like

    Enum2 getEnum2mapping (Enum1 _enum1)
    {
         if (_enum1 == Enum1::Eval1)
         return Enum2::Eval3;
         else
         return Enum2::Eval4;
    }

    you use the method in code

    Table1 table1;
    Table2 table2;
    Enum2 enum2Var;

    while select field1 from table1
    {
            enum2Var =   getEnum2mapping (table1.field1); // calling the mapping method

           select * from table2 where table2.field1 = enum2Var;  // here you can get the result
    }

    Thanks
    Amir
    https:://msdax.wordpress.com

     

     

     

     

     

     

  • Community Member Profile Picture
    on at

    because in table2 enum only few values from table1 enum is there. that the reson edt type is different

    my question is

    table1, field1, enum1 with values (Eval1,Eval2)

    this is hardcode i have to do eval1 eval2..

  • Community Member Profile Picture
    on at

    Can you pls elaborate it how to write the above code in my forms where do i specify this method

    my forms are Security transaction and other is Precleance breach and both is having field Trancsaction type with enum ITL_COC_TransactionType and other is ITL_COC_PreclType

    pls elaborated in forms coding

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans