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

(more…)