AX 7. Get information about table extension using Microsoft.Dynamics.Ax.Xpp.MetadataSupport

In AX 2012 we used DictTable class to get information about tables, table fields, indexes and field groups. However we cannot retrieve any information about table extensions using this class, so Microsoft.Dynamics.Ax.Xpp.MetadataSupport was introduced in AX 7.

Let’s look at simple job that will return all table extensions and all fields from table extensions for CompanyInfo table.

public static void main(Args _args)
    var axTableExtensions = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetTableExtensionsForTable(tableStr(CompanyInfo));
    System.Collections.IEnumerator axTableExtensionsEnumerator = axTableExtensions.GetEnumerator();

    while (axTableExtensionsEnumerator.moveNext())
        Microsoft.Dynamics.AX.Metadata.MetaModel.AxTableExtension axTableExtension = axTableExtensionsEnumerator.get_Current();

        info(strFmt("Extension name %1", axTableExtension.Name));

        var axTableExtensionFields = axTableExtension.Fields;

        System.Collections.IEnumerator axTableExtensionFieldsEnumerator = axTableExtensionFields.GetEnumerator();

        while (axTableExtensionFieldsEnumerator.moveNext())
            Microsoft.Dynamics.AX.Metadata.MetaModel.AxTableField axTableExtensionField = axTableExtensionFieldsEnumerator.get_Current();

            info(strFmt("Field name %1", axTableExtensionField.Name));
            info(strFmt("Mandatory %1", axTableExtensionField.Mandatory));
            info(strFmt("Allow edit %1", axTableExtensionField.AllowEdit));

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s