Tuesday, March 1, 2011

How to get a list of all tables within the AOT

Our challenge for today: Get a complete list of all tables within the AOT.

We could try to use table UtilElements for that, but please bear in mind that you would get multiple listings for the same table if it exists in different layers.

We gonna use a slightly different approach, by using the Dictionary class of Dynamics Ax.  This class provides us with the necessary information from the AOT.

static void TableList(Args _args)
{
    tableId         tableId;
    int             tablecounter;
    Dictionary      dict = new Dictionary();

    for (tablecounter=1; tablecounter<=dict.tableCnt(); tablecounter++)
    {
        tableId = dict.tableCnt2Id(tablecounter);
        info(dict.tableName(tableId));
    }
}

2 comments:

  1. Dziękuję, pomogło.

    ReplyDelete
  2. above code will list the map, which is not our expectation.

    ReplyDelete