02.04.2007, 16:50
|
#1
|
Участник
|
casperkamal: Adding a Table field through X++ code in Dynamics Ax
Источник: http://casperkamal.spaces.live.com/B...CD63!258.entry
==============
Sometime back there was a query in one of the discussion forum about inserting a table field through code. I did a small job to demonstrate that, just thought would write that down in my blog too...... and here it is.
I have added sufficient comments to make it explanatory.
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');
//get the properties structure
properties = fieldNode.AOTgetPropertiesExt();
//Update the properties map with the required properties
map.insert('ExtendedDataType', 'LedgerAccount');
// get the number of properties
// and the array containing the properties structure
propertyCount = properties.value('Entries');
propertyArray = properties.value('PropertyInfo');
for (i = 1; i < propertyCount; i ++)
{
propertyInfo = propertyArray.value(i);
name = propertyInfo.value('Name');
//see if we have inserted the property name in to the map
if (map.exists(name))
{
//set the property
propertyInfo.value('Value', map.lookup(name));
}
}
//set the properties structure
fieldNode.AOTsetPropertiesExt(properties);
//save the treenode
tablenode.AOTsave();
//Let us open the table
//and see if the code works :)
tablenode.AOTnewWindow();
}
click to download it from Axaptapedia
..........................

Источник: http://casperkamal.spaces.live.com/B...CD63!258.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|
|
За это сообщение автора поблагодарили: alex55 (1). |