I have been experimenting with getting Metadata information from the AOT from FinOps. There is some discussion on this forum post which helped me.
https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/316468/how-to-get-aot-objects
I thought I would try to clean it up a bit to make it a bit more readable for future reference.
The X++ code below will loop through Display menu items in the AOT and print some info.
https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/316468/how-to-get-aot-objects
I thought I would try to clean it up a bit to make it a bit more readable for future reference.
The X++ code below will loop through Display menu items in the AOT and print some info.
- Menu Item Name
- Menu Item Label
- Model Name
public static void main (Args _args)
{
System.Type axMenuItemTypeDisplay = new Microsoft.Dynamics.AX.Metadata.MetaModel.AxMenuItemDisplay ().GetType ();
System.Collections.Specialized.StringEnumerator menuItemDisplayNames = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::MenuItemDisplayNames ();
while (menuItemDisplayNames.moveNext ())
{
str menuItemName = menuItemDisplayNames.get_current ();
//Get Model Name for the display menu item
var enum = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetModelsOfMetadataArtifact (menuItemName, axMenuItemTypeDisplay).GetEnumerator ();
str modelName = enum.moveNext () ? enum.Current.DisplayName : '';
MenuFunction menuFunction = new MenuFunction (menuItemName, MenuItemType::Display);
info (strFmt ("menuItemName: %1, menuItemLabel: %2, modelName: %3",
menuItemName,
menuFunction.label (),
modelName
));
}
}