Overview - How to get the primary table from an entity in D365F&O
public static TableName getPrimaryTable(TableName _tableName)
{
TableName tableName;
Query q;
QueryBuildDataSource dataSource;
DictDataEntity dictEntity = new DictDataEntity(tableName2Id(_tableName));
if (dictEntity)
{
q = dictEntity.query();
if (q.dataSourceCount() >= 1)
{
dataSource = q.dataSourceNo(1);
if (dataSource)
{
tableName = tableId2Name(dataSource.table());
}
}
}
return tableName;
}
And if we need all tables from the data entity, we can loop the data source count.
#D365F&O #AX #Entities
public static TableName getPrimaryTable(TableName _tableName)
{
TableName tableName;
Query q;
QueryBuildDataSource dataSource;
DictDataEntity dictEntity = new DictDataEntity(tableName2Id(_tableName));
if (dictEntity)
{
q = dictEntity.query();
if (q.dataSourceCount() >= 1)
{
dataSource = q.dataSourceNo(1);
if (dataSource)
{
tableName = tableId2Name(dataSource.table());
}
}
}
return tableName;
}
And if we need all tables from the data entity, we can loop the data source count.
#D365F&O #AX #Entities