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)

_Model databases - newbie questions

(0) ShareShare
ReportReport
Posted on by 135

Hi all, I'm an experienced developer but new to AX development.

A tool I'm developing will have to read AOT enums externally.

By which I mean it will need to check the enums to see if there are customised values etc.

The tool will have permission to read databases but will almost certainly not have access to the dlls for reading AOT data.

For AX2012R2 installations it looks like I can get what I need from the xxxxx_Model database but I can not find as much detail as I'd like about how the tables are related to each other and to the AOT.

For earlier versions of AX2012 and for legacy versions AX2009 and AX4 I've seen hints on various websites that the AOT data is held in tables in the main AX database but I haven't found out more detail - which tables they are would be an excellent thing to know :)

Can anybody point me at appropriate documentation?

Thanks

Hetoo

*This post is locked for comments

I have the same question (0)
  • Verified answer
    PA-22040759-0 Profile Picture
    6,194 on at

    The SysModelElement table would be the main table to base your search on.

    The "Inside Microsoft Dynamics AX 2012" book has a chapter on reflection where you can see a diagram with the datamodel for the model store.

  • Hetoo Profile Picture
    135 on at

    Thanks Palle, I will obtain and read it.

  • Martin Dráb Profile Picture
    239,022 Most Valuable Professional on at

    I would suggest another approach - the metadata service (operations GetEnumNames, GetEnumMetadataByName and GetEnumMetadataByID).

  • Hetoo Profile Picture
    135 on at

    Thanks Martin. I've checked that out and it looks promising for AX2012, unfortunately I also have to support AX2009 and maybe AX4  which I think are going to be awkward.

  • Martin Dráb Profile Picture
    239,022 Most Valuable Professional on at

    Sorry, I got confused by the fact that the thread title and the verified answer are about the model database, which is a new feature of AX2012 in the same way as the metadata service. In AX4/2009, you'll have to use reflection (SysDictEnum class) to get information you need and somehow expose it outside AX (Business Connector, web service, data export...).

  • Hetoo Profile Picture
    135 on at

    Yes, I thought as much. I've already drafted an X++ script which writes out the things I need. I was hoping to do it without needing that. The data MUST be stored somewhere. Maybe I'll have a go the "AOD" files I've seen mentioned. Thanks again.

  • Dale Thornton Profile Picture
    on at

    Hi Hetoo,

    I think your requirement is similar to mine. We have to display the enum descriptions from SQL stored procedures for external reporting. In AX2009 we could do this by using the SRSAnalysisEnums table but in AX2012 it is a lot more difficult to get the descriptions externally especially if performance is important.

    Our solution has been to create a table that contains all the enums and descriptions which we can query externally. Any time we edit the enums in the AOT we just need to run a job to refresh the table.

    The table (EnumLabels) contains the following fields:
    EnumID (EDT EnumID)
    EnumName (EDT EnumName)
    Label (EDT LabelString) 

    And the following table methods help us populate the table:

    // Use the following method to add or update an enum's labels.
    public static void PopulateEnum(EnumName enumName)
    {
        EnumLabels enumLabels;
        DictEnum enum = new DictEnum(enumName2Id(enumName));
        int i;
        ;

        ttsBegin;

        delete_from enumLabels where enumLabels.EnumName == enumName;

        for (i=0; i < enum.values(); i++)
        {
            enumLabels.initValue();
            enumLabels.EnumName = enumName;
            enumLabels.EnumId = enum.index2Value(i);
            enumLabels.Label = enum.index2Label(i);
            enumLabels.insert();
        }

        ttsCommit;
    }

    // Use the following method to add or update all enums under the AOT.
    // Note this will exclude system enums which do not appear in the AOT, these need to be added by the PopulateEnum method where needed.
    public static void PopulateEnumsFromAOT()
    {
        Treenode enumsNode;
        Treenode enumNode;
        EnumName enumName;
        int i;
        int nodeCount;
        ;

        enumsNode = treenode::findNode('\\Data Dictionary\\Base Enums');

        nodeCount = enumsNode.AOTchildNodeCount();
        enumNode = enumsNode.AOTfirstChild();

        for (i=1; i<=nodeCount; ++i)
        {
            enumName = enumNode.AOTgetProperty("Name");

            EnumLabels::PopulateEnum(enumName);

            enumNode = enumNode.AOTnextSibling();
        }
    }


  • Martin Dráb Profile Picture
    239,022 Most Valuable Professional on at

    @Hetto: Of course it's in AOD files (= layers), but how will you read it? The answer is: through the reflection API (Dict*/SysDict* classes).

    @Dale Thornton: You can get a set of all enums by calling new SysDictionary.enums(), or write the loop by yourself with the help of Dictionary.enumCnt2Id() or Dictionary.enumNext(), if you don't want to store the whole set in memory (that's usually the approach I choose).

  • Hetoo Profile Picture
    135 on at

    Hi Dale, Thanks very much for the detailed reply. I will almost certainly adopt an approach like the one you have implemented and the code snippets will be very useful for doing so.

  • Hetoo Profile Picture
    135 on at

    The thing I'm writing is a 3rd party tool and we assume minimum security read-only access to the AX database and Model database, often by staging rather than directly. If AX2009 clients want the extra functionality afforded by customised enums then it seems we'd need elevated security permissions, one way or another.  

    I'm really impressed with this forum, guys, you've all given excellent and relevant advice and I now know the approach we'll need to take.

    Thanks very much everybody.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans