views:

202

answers:

1

In Microsoft Dynamics AX, how do I get a list of methods on a table from C#?

+1  A: 

The X++ method below takes the table name as a parameter and returns an ArrayList of the methods. You can call X++ static metods from your C# code (you need the .Net Business Connector for that).

public static System.Collections.ArrayList getTableMethods(str _tableName)
{
    SysDictTable sdt;
    TreeNode tn;
    TableId tableId;
    MethodInfo methodInfo;
    System.Collections.ArrayList methodArr;
    #AOT
    ;

    tableId = tableName2id(_tableName);

    sdt = SysDictTable::newTableId(tableid);

    methodArr = new System.Collections.ArrayList();
    tn = TreeNode::findNode(#TablesPath + "\\" + _tableName + "\\" + "Methods");
    tn = tn.AOTfirstChild();
    while(tn)
    {
        methodArr.Add(tn.AOTname());
        tn = tn.AOTnextSibling();
    }

    return methodArr;
}
Velislav Marinov