Find out tables containing specific EDT

Sometimes we need to know the tables of which fields are containing given EDTs. For instance, I want to find out all the tables that contain the fields of EDT ProjCategoryId.
Following is the code:
static void findTableWithProjCategoryId(Args _args)
{
    xInfo xInfo = new xInfo();

    treeNode t = xInfo.rootNode().AOTfindChild("DataDictionary").AOTfindChild("Tables");
    treeNode childNode;
    treeNode fields;
    treenodeIterator it, itFld;

    str properties;
    str table;
    str field;
    str extendedDataType;
    str searchType = "ProjCategoryId";
    ;

    it = t.AOTiterator();
    childNode= it.next();
    while (childNode)
    {
      Table = child.treeNodeName();
      itFld = t.AOTfindChild(child.treeNodeName()).AOTfindChild("Fields").AOTiterator();

      fields = itFld.next();
      while (fields)
      {
        field = fields.treeNodeName();
        properties = fields.AOTgetProperties();
        extendedDataType = findProperty(properties, "ExtendedDataType");

        if (extendedDataType == searchType)
        {
          info(strfmt("%1 / %2 – ExtendedDataType: %3", table, field, extendedDataType));
        }
        fields = itFld.next();
      }
      childNode= it.next();
    }
}

Advertisements
This entry was posted in Axapta Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s