04 October 2010

Add Fields to a table, using X++ code_not the AOT In Dynamics Ax

// Create a New table in AOT with the name of moDocuref

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();
}

No comments:

Post a Comment

Give me the commetns and solutions

DB restore production DB to DEV environment in D365 FO using Bacpac file

  https://www.linkedin.com/pulse/restore-production-database-dev-environment-d365fo-using-abbas-tfwbe SQLPackage link : https://www.linkedin...