当前位置: 首页 > 工具软件 > CodeCreate > 使用案例 >

Use X++ code create table

汝和裕
2023-12-01

用X++代码创建表

用代码创建表的代码,在这里记录一下:

                        static void CreateNewTable(Args _args)
{
#AOT
TreeNode treeNode = TreeNode::findNode(#TablesPath);
DictType dictType;
TreeNode treeNodeField;
str tableName = 'Student';
str fieldName1 = 'StudentNum';
str fieldName2 = 'StudentName';
AOTTableFieldList afl;
str property;

void addField(str fieldName,str label,str HelpText,str ExtendedDataTypeName)
{
afl.addString(fieldName);
property = strFmt(@"Properties
Label #%1
HelpText #%2
ExtendedDataType #%3
EndProperties
",label,HelpText,ExtendedDataTypeName);
treeNodeField = afl.AOTfindChild(fieldName);


treeNodeField.AOTsetProperties(property);
}
;
//Add Table;
treeNode = treeNode.AOTadd(tableName);

//Add Fields
afl = treeNode.AOTfirstChild();
addField(fieldName1,"Student Number","The Number of Student.","AccountNum");
addField(fieldName2,"Student Name","The Name of Student.","AccountName");

//Save
treeNode.AOTcompile(1);
treeNode.AOTsave();

//Restore Extended Data Type's Properties
treeNode.AOTrestore();

//Synchronize Table
appl.dbSynchronize(SysDictTable::newTreeNode(treeNode).id());

}

 

转载于:https://www.cnblogs.com/yuankang/archive/2012/04/10/2440297.html

 类似资料:

相关阅读

相关文章

相关问答