How to get table name and number of records in each table in AOT

How to get table name and number of records in each table in AOT

MCP · Azure DevOpsYour delivery board, readable by an agentMCP · DataverseOne consent, and the data layer opensMCP · Dynamics 365 F&OConnecting F&O to an agent Microsoft hasn’t documented
Archive recovery note: the supplied Blogspot backup did not contain a separate saved page for this older entry. The text available in its archive/listing capture has been preserved and flagged for a later completeness check.
Today, I came across a requirement to find out the name of each table in AOT along with the number of records for each table. Here is the code to achieve this functionality; void getTableNameRecordCount(Args _args) {     #AOT Name name;     NumberOf recordCount;     TreeNode treeNode;     SysDictTable sysDictTable;     ;     treeNode = TreeNode::findNode(#TablesPath);     treeNode = treeNode.AOTfirstChild();     while (treeNode)     {         name = treeNode.AOTname();         sysDictTable = SysDictTable::newTableId(treeNode.applObjectId());         recordCount = sysDictTable.recordCount(false);         if (recordCount)         info (strfmt("@SYS26868", name, recordCount));         treeNode = treeNode.AOTnextSibling();     } }
Previous article← Inside MS Dynamics AX 4.0 and MORPHIX IT
Discussion

Ask a question or leave feedback

This is a review interaction. The WordPress version will store, thread and moderate comments.

Thanks — submitted for moderation in this review.
Search the whole site · Ctrl/⌘ + K