Home > Ax Technical > A small addition to creation of Table throug x++ code in Dynamics Ax

A small addition to creation of Table throug x++ code in Dynamics Ax

 
 
   A small addition to my entry on Adding a Table field through X++ code in Dynamics Ax
 
 
      I was actually using map’s and structures to set the properties for the field type. There is also an alternative way of setting it throug the Global::setproperty method….
 
 
  Global::setProperty(str properties, str propertyname, str value) 
 
 I have rewritten the job based on that…….
 
static void JobCreateTableFields(Args _args)
{
   
#AOT
    #TreeNodeSysNodeType

    //find the Table
   
TreeNode                   tablenode = TreeNode::findNode(#TablesPath).AOTfindChild(‘LedgerTable’);
    TreeNode                   fieldNode, tn;
    Struct                         properties;
    Struct                         propertyInfo;
    Array                          propertyArray;
    str                               propertyValue;
   
AOTTableFieldList    lst;
    str                               name;
    Counter                     propertyCount;
    int                               i;
    Map                            map = new Map(Types::String, Types::String);
    ;
 
    //Find the tables field node
   
lst = tablenode.AOTfindChild(‘fields’);
    //add the field
    lst.addString(‘Test’);
    //now find the node in the tree
    fieldNode  =  lst.AOTfindChild(‘Test’);
   
    //can be used when we requried to set a fewer properties
 
    fieldNode.AOTsetProperties(setProperty(fieldNode.AOTgetProperties(), ‘Label’, ‘TestField’));
 
     //save the treenode
    tablenode.AOTsave();
   
   
//Let us open the table
    //and see if the code works 🙂
    tablenode.AOTnewWindow();
 
 

………………………..

Advertisements
  1. srinu
    January 18, 2013 at 1:18 pm

    nice but i want root node given child nodes to be print,using x++ code

  2. Puja.G.B
    November 15, 2011 at 6:21 am

    Very Nice work… It helped me…

    Thanks
    Puja.G.B.

  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: