Site icon DAXRunBase

AOT property for kernel objects are readable via reflection

There was a question recently on the Dynamics Community forums about finding out which enumeration to use behind an int type. It turned out that the table, field and enum in question was part of the kernel. Those entries reside under the System documentation node of the AOT, and they do not provide much meaningful details. Reflection works on them as well, so you could use the tooling the same way as on regular objects (Dict*, TreeNode objects). Here is a code snippet to read the AOT property for kernel objects.

static void Job1(Args _args)
{
    info(strFmt('%1',
        enumId2Name(
            new DictField(
                tableNum(SecurityPermission),
                fieldNum(SecurityPermission, Access))
            .enumId()))
        );
}

You may also find some examples within the official documentation on how to use reflection. This example is getting class decoration of a method:
https://docs.microsoft.com/en-us/dynamicsax-2012/developer/how-to-use-reflection-to-get-attribute-class-metadata

A fellow blogger, SysDictCoder has published some details on it as well about a decade ago.
http://sysdictcoder.com/changing-properties-of-aot-objects-in-code/

You can do some really neat tricks, like compiling and executing custom code runtime with the XppCompiler framework (similar to RunBuf).

This tradition has been kept in Microsoft Dynamics 365 for Finance and Operations as well. It went through a lot of changes though, starting with keeping the source code (ModelStore) in an XML structure. Joris has a series of articles worth reading about the topic.

The new way of accessing this information is through MetaData providers. You can find some excellent articles on the topic, here are some examples:

http://dev.goshoom.net/en/2016/11/new-metadata-api/

https://gist.github.com/mazzy-ax/4d4d06ec2fddd885b67527623467aee8

I also had to play around with MetaData a bit in MSDyn365FO related to our code upgrade. Peter Villadsen from Microsoft gave a great idea during the Microsoft Technical Conference couple of years back. My next post will be about that, using the tool called BaseX to scan the source files for valuable information.

Exit mobile version