In Microsoft Dynamics AX, how to get a look up of all the tables available in AOT

This article explains you how to get a look up to a control for All the AOT tables and can answer to below relevant questions.
·  Create a look up to show all the tables from AOT.
·  How to develop a drop down to show all the AOT tables where user can select one among?
·  How to create an edit method in Microsoft Dynamics AX?

Applied on: Dynamics AX 2012 R2 
Prerequisite: X++; MorphX; Basic programming knowledge 
Target audience: Any



Output: Look up of all the AOT tables

Create a table with a single field. Here my table name is TableLookUp with field name TableObjID.
The field should be extended to RefTableId EDT as shown below.

Write an edit method to your table. I wrote a method in the name of tableObject2Name. The method looks like:

// This method returns table name
// BP deviation documented
edit TableName tableObject2Name(boolean _set, TableName _name) // System Documentation>Type>TableName
    Dictionary dictionary;
    TableId tableID;

    if (_set)
        dictionary = new Dictionary(); // System Documentation>Classes>Dictionary
        tableID = dictionary.tableName2Id(_name);

        if (tableID)
            this.TableObjID = tableID;
    return tableid2name(this.TableObjID);

Create a new form and use the table you created as data sources and method to get a control.
Here my form looks like:


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.