Tuesday 2 October 2018

Dynamics AX R3 | List of all tables with details

In one of the recent projects, I had to pull the details of all the tables with their current record counts and if they are the part of any country specific localisation. I used the following code to pull those details. Nice simple code got the job done well.
static void GetTablesDetails(Args _args)

{
    #AOT
    #File
    #Properties

    CommaIo csvIO;
    str description;
    TreeNode tables;
    int total, counter;
  ;

    csvIO = new CommaIo(@"c:\AX_tables_details.csv", #IO_WRITE);
    csvIO.write("No","TableName""ID","LegacyId","SaveDataPerCompany","TableGroup","FormRef","CountryRegionCodes","RecordsCount");
    tables = TreeNode::findNode(@"\Data Dictionary\Tables");
    total = tables.AOTchildNodeCount();
    tables = tables.AOTfirstChild();

    for(counter = 1; counter <= total; counter++)
    {
       
        csvIO.write(counter,tables.AOTgetProperty("Name"),tables.AOTgetProperty("ID"),tables.AOTgetProperty("LegacyId"),tables.AOTgetProperty("SaveDataPerCompany"),tables.AOTgetProperty("TableGroup"),tables.AOTgetProperty("FormRef"),tables.AOTgetProperty("CountryRegionCodes"),SysDictTable::casRecordCount(tables.AOTname()));
        tables = tables.AOTnextSibling();
     }

    info("Done");
}

No comments:

Post a Comment