Create Table With Properties Using X++
static void CreateTableWithProperties(Args _args)
{
treenode trv;
AOTTableFieldList fieldnode,childfieldnode;
str prop,oldname,newname;
int pos;
#AOT
#Properties
trv = treenode::findNode(#TablesPath);
trv.AOTadd('SimpleTestTable');
trv = trv.AOTfindChild('SimpleTestTable');
trv.AOTcompile(1);
trv.AOTsave();
//filedlist = treenode::AOTfieldchild(TableName).AOTfindchild('Fileds');
trv.AOTfindChild('SimpleTestTable');
fieldnode = trv.AOTfirstChild();
// adding fields
fieldnode.addString('SimpleStringField');
childfieldnode = fieldnode.AOTfindChild('SimpleStringField');
childfieldnode.AOTsetProperty(#PropertyExtendeddatatype,"Name");
fieldnode.addReal('SimpleRealField');
childfieldnode = fieldnode.AOTfindChild('SimpleRealField');
childfieldnode.AOTsetProperty(#PropertyExtendeddatatype,"Amount");
childfieldnode.AOTsetProperty(#PropertyLabel,"My Salary");
fieldnode.addInteger('SimpleIntegerField');
childfieldnode = fieldnode.AOTfindChild('SimpleIntegerField');
childfieldnode.AOTsetProperty(#PropertyLabel,"My Employee Id");
fieldnode.addDate('SimpleDateField');
childfieldnode = fieldnode.AOTfindChild('SimpleDateField');
childfieldnode.AOTsetProperty(#PropertyLabel,"My Sample Date");
childfieldnode.AOTsetProperty(#PropertyExtendeddatatype,"TransDate");
fieldnode.addTime('SimpleTimeField');
childfieldnode.AOTsetProperty(#PropertyLabel,"My Sample Date");
trv.AOTcompile(1);
trv.AOTsave();
trv.AOTcompile(1);
sqlDataDictionary::Synchronize();
trv.AOTrestore();
}
No comments:
Post a Comment