Dynamics AX

Welcome to my Dynamics AX playground!

Home     Articles     Dynamics AX - Trivia     Dynamics AX Search     Mohammed Rasheed     Contact Me     My Dynamics Ax Blog      
Guide to Setup SSRS with
Add Fields to a Table Using Code
Code to view Ledger Transaction Details
AX Mobile - Installation and Configuration
Forecasting in Dynamics AX 2009
Multi Threaded Programming in DAX
OLAP - Installation and Configuration
Send Text Messages (SMS) from DAX
Sending Emails from DAX without Outlook.
Using Data Definition Groups
A View Thing..
All About Maps..
COM Class Wrapper
Create a Role Centre
Create and Post Counting
Outlook 07 Integration
Alerts to Multiple Users
Counting Lines of Code
 
 

Add Fields to a table, using code.... not the AOT... In Dynamics AX

 

 

static void createFieldFromCode(Args _args)

{

 

    #AOT

    TreeNode            tableNode;

    AotTableFieldList   myAOTTablefieldList;

    SysDictTable   sysDictTable = new SysDictTable(tablenum(moDocuref));

 

    ;

   if (! hasSecuritykeyAccess(securitykeynum(SysDevelopment),

          AccessType::View))

    {

        return;

    }

 

    myAOTTablefieldList = new AotTableFieldList();

 

    tableNode = TreeNode::findNode(#TablesPath+'\\'+sysDictTable.name());

 

    myAOTTablefieldList =

TreeNode::findNode(#TablesPath+'\\'+sysDictTable.name() + "\\Fields");

 

 

    if(!myAOTTablefieldList.AOTfindChild("newField")) // check if the field

alredy exists

    {

        myAOTTablefieldList.addString("newField");

    }

 

   tableNode.AOTsave();  

}