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)

Retrieve enum id from table-field-id

(0) ShareShare
ReportReport
Posted on by 320

Hi,

In Dynamics AX 2012, a field from a table can be extended from an enum type (or indirectly via an extended data type which is extended from an enum type). In order to have easy access to the enum elements value within SQL Server I'm trying to find my way through the table structures. Ultimately the data is used in PowerBI inquiries.

Please, does someone know the answer to this question: what table(s) must I use to find the connection between a table.field to the extended enum type?

 

Example

-- List all tables with their enum based fields

SELECT * FROM SQLDICTIONAIRY WHERE FIELDTYPE=4;

 

-- A bit more specific test: Only select the blocked field of the CustTable

SELECT * FROM MODELELEMENT WHERE PARENTID=77 AND AXID=14;

 

--  List the specific enum type

SELECT * FROM SRSMODELENTITYCACHE WHERE ENTITYTYPE=2 AND INSTANCESELECTION='Dropdown';

-- WHERE ...

 

I suspect I also need information on the tables field object within the model it was created/changed. What am I missing here in SQL?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

    Hi. You can just use SysDictField to do this...

    SysDictField field = new SysDictField(tableNum(PurchReqTable), fieldNum(PurchReqTable, Requisitionstatus));

       info(strFmt("Enum Id: %1",field.enumId());

  • botten Profile Picture
    320 on at

    Thanks Jonathan,

    But do you also know how to retrieve this information from within SQL Server?

  • Jonathan  Halland Profile Picture
    11,310 on at

    Sorry, I'm not sure if you will be able to do so in SQl

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    It should be somewhere in the model store, but external systems shouldn't use AX database directly (the structure can change without warning etc.).  They're supposed to use the metadata service.

  • Suggested answer
    botten Profile Picture
    320 on at

    Thanks for your answers.

    The best solution for me now is to create a Dynamics AX view. That way I can use the internal AX frameworks and add what ever meta data through static methods.

    But I can't help and think that there must be a more efficient SQL way to solve this.

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    There may be a more efficient way to solve your problem, but you would have to tell us what you're trying to achieve. Without knowing your actual business requirement, nobody can suggest any better technical solution. We could only micro-optimize the solution you've already chosen, regardless that you would like "a more efficient way".

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
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans