using Microsoft.Dynamics.AX.Metadata.MetaModel; class VKTest { Map edtMap; List edtList; str edtListText; str fieldListText; public static void main(Args _args) { VKTest vkTest = new VKTest(); vkTest.buildEDTList(); vkTest.tableList2(); vkTest.outputResults(); Info('Done'); } public void outputResults() { Info(edtListText); Info(fieldListText); } public void buildEDTList() { DictType dictType = new DictType(extendedTypeNum(WeightBase)); edtList = dictType.extendedBy(true); //Info(strFmt("EDT count: %1", edtList.elements())); edtMap = new Map(Types::Integer, Types::Integer); ListEnumerator le = edtList.getEnumerator(); while (le.movenext()) { edtListText += extendedTypeId2name(le.current()) + "\n"; edtMap.insert(le.current(), 1); //Info(strFmt("%1", le.current())); } } // walk through all tables and fields, using TreeNode public void tableList1() { TreeNode treeNode; xInfo xInfo = new xInfo(); #AOT treeNode = xInfo.findNode(#TablesPath); treeNode = treeNode.AOTfirstChild(); /* // To directly iterate through table fields TableName tableName = tableStr(SalesLine); treeNode = xInfo.findNode(#TablesPath + "\\" + tableName); treeNode = treeNode.AOTfindChild('Fields'); treeNode = treeNode.AOTfirstChild(); */ while (treeNode) { info(treeNode.treeNodeName()); DictTable table = new DictTable(tableName2Id(treeNode.treeNodeName())); DictField field; FieldId fieldId = table.fieldNext(0); while(fieldId) { field = table.fieldObject(fieldId); if(field.isSql() && !field.isSystem()) { /* field.tableid(); field.id(); field.name(); field.label(); field.help(); */ //Info(strFmt("%1.%2: %3", table.name(), field.name(), extendedTypeId2name(field.typeId()))); } fieldId = table.fieldNext(fieldId); } treeNode = treeNode.AOTnextSibling(); break; } } // walk through all tables and fields, using Dictionary public void tableList2() { Dictionary dict = new Dictionary(); TableId tableId; tableId = dict.tableNext(0); while (tableId) { if(dict.tableSql(TableId)) { DictTable table = dict.tableObject(tableId); DictField field; FieldId fieldId = table.fieldNext(0); while(fieldId) { field = table.fieldObject(fieldId); if(field.isSql() && !field.isSystem()) { /* field.tableid(); field.id(); field.name(); field.label(); field.help(); */ // Info(strFmt("%1.%2: %3", table.name(), field.name(), extendedTypeId2name(field.typeId()))); if (Types::Real == field.baseType()) { this.checkField2(table, field); //break; } } fieldId = table.fieldNext(fieldId); } } tableId = dict.tableNext(TableId); //break; } } // walk through all tables and fields, using MetadataSupport public void tableList3() { TableId tableId; var tables = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetAllTables(); var tableEnum = tables.GetEnumerator(); while(tableEnum.MoveNext()) { /* using Microsoft.Dynamics.AX.Metadata.MetaModel; or full name Microsoft.Dynamics.AX.Metadata.MetaModel.AxTable */ AxTable table = tableEnum.Current; tableId = tableName2Id(table.Name); /* table.Name; table.Label; table.SaveDataPerCompany */ var fieldEnum = table.Fields.GetEnumerator(); while(fieldEnum.MoveNext()) { AxTableField field = fieldEnum.Current; int fieldId = fieldName2Id(tableId, field.name); /* field.Name; field.Label; field.HelpText; field.AssetClassification; */ Info(strFmt("%1.%2: %3", table.Name, field.Name, field.ExtendedDataType)); } break; } } public void checkField2(DictTable _table, DictField _field) { int typeId = _field.typeId(); if (edtMap.exists(typeId)) { str line = strFmt("%1(%2).%3(%4): %3", _table.name(), _table.label(), _field.name(), _field.label(), extendedTypeId2name(typeId)); fieldListText += line + "\n"; } } }For example, check which fields will be affected when changing decimal point precision: https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/extensibility/decimal-point-precision
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.
Authors are allowed to set their own AdSense units.
Join us.