Need to show count of specific tables in infolog

Hi Experts,

I would like to count the tables which has ABC prefix (Ex:ABCVendTable, ABCSalesTable) in D365.

I have used this the below code to count all D365 tables and it worked.

static void daxCountTablesInAX(Args _args)
// Count of all the tables.
info (strFmt(“Tables in AX: %1”, treenode::findNode(’\Data Dictionary\Tables’).AOTchildNodeCount()));

But now i want to count the tables which starts with ABC.

Please guide me to find this. I am new to D365 f&o Development.

Thanks in Advance,

Let me format your coee to make it easier to read. Next time, please use do that by yourself. Notice the </> button in the toolbar.

static void daxCountTablesInAX(Args _args)
    // Count of all the tables.
    int numOfTables = TreeNode::findNode('\Data Dictionary\Tables').AOTchildNodeCount());
    info(strFmt("Tables in AX: %1", numOfTables);

Unfortunately this solution won’t help you in your case. It’s not enough to count all the nodes; you need to iterate them and check if the name is what you wanted.
You can either use the old TreeNode API (e.g. with TreeNodeIterator), or the new metadata API (e.g. through Microsoft.Dynamics.Ax.Xpp.MetadataSupport).
But before writing code, consider whether it’s the right approach. What is it the business problem that you’re trying to solve? For example, if you want to find tables created by your company, shouldn’t you check the model rather than the prefix?

Hi Martin,

Thanks for your reply. Below is the new business need.

New requirement:

I have a BYOD setup and its working. I need to match the records count of AX original tables as well as BYOD (verify record count between AX table and table for published entity in BYOD ).

I have written a code to count the records of AX tables those are involved in entity creation.

But now i need to count the records of BYOD published data. How can i proceed this? Is there any ways.

Thanks in advance,

Please don’t change the topic - create a new thread (with an appropriate title and tags) for your new question. Also, add more information there - it’s not clear at all where you need to access the information and when, if you want to count records for a particular ExecutionId and so on…

Do you need anything more on the topic of this thread (Need to show count of specific tables in infolog)? If so, please explain what it is. If not, please consider verifying the answer.

Yes martin. Treenode iterator helped me to find the records starts with prefix. Thanks.

As you suggested, I will make a new thread for new requirement.