table methods) we should keep in mind to use the below namespace in our code.
using Microsoft.Dynamics.AX.Metadata.MetaModel;
To get list of tables
using Microsoft.Dynamics.AX.Metadata.MetaModel;
public class TableNamesList
{
public static void getTableNames()
{
var tables = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetAllTables();
var tablesEnumr = tables.GetEnumerator();
while (tablesEnumr.MoveNext())
{
info(strfmt("%1", axTable.Name));
}
}
}
To get list of Fields from a table
public static void getFieldNames()
{
AxTable table = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetTable(tableId2Name(tablenum(SalesTable)));
var fields = table.Fields;
var fieldEnumerator = fields.GetEnumerator();
while (fieldEnumerator.MoveNext())
{
info(strfmt("%1", field.Name));
}
}
To get list of methods available on a table
public static void getMethodNames()
{
AxTable table = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetTable(tableId2Name(tablenum(SalesTable)));
var methods = table.Methods;
var methodEnumerator = methods.GetEnumerator();
while (methodEnumerator.MoveNext())
{
AxMethod method = methodEnumerator.Current;
if(method.IsDisplay)
{
info(strfmt("Display method : %1", method.Name));
}
else
{
info(strfmt("Normal method : %1", method.Name));
}
}
}
Similar to the above code, we can use the metadata .dll in X++
to get all the objects and its related details available in AOT