Add Fields to a table, using code.... not the AOT.. In Dynamics AX
Do you like this story?
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();
}
http://www.dynamic-ax.co.uk/
This post was written by: Rahil Anouar
Rahil Anouar is a professional blogger, web designer and Linux user. Follow him on Twitter
0 Responses to “Add Fields to a table, using code.... not the AOT.. In Dynamics AX”
Post a Comment