使用代码向AOT中添加新结构(表/类等)

使用Code向类添加方法

使用Code向表中添加字段

使用Code创建EDT

 

使用Code向类添加方法:

static void DavidTest(Args _args) { TreeNode treeNodeFields,treeNodeField,treeNodeJobs, treeNodeJob; int i = 0; str content; #AOT ; treeNodeFields = TreeNode::findNode(#TablesPath+' //InventTable//Fields'); treeNodeJobs = TreeNode::findNode(' //Jobs'); treeNodeJob = treeNodeJobs.AOTadd("DavidTesting");//AOTaddSubNode(NodeType::Jobs); content = "static void DavidTesting(Args _args)/n"; content = content + "{/n"; content = content + " InventTable inventTableSource, inventTableDest;/n"; content = content + ";/n"; content = content + " /n"; treeNodeField = treeNodeFields.AOTfirstChild(); while (treeNodeField) { content = content + "inventTableDest." + treeNodeField.AOTname(); content = content + " = "; content = content + "inventTableSource." + treeNodeField.AOTname(); content = content + ";/n"; treeNodeField = treeNodeField.AOTnextSibling(); } content = content + "}"; treeNodeJob.AOTsetSource(content); treeNodeJob.AOTsave(); }  

 

使用Code向表中添加字段:

转自:http://dynamic-ax.co.uk/DynamicsAXAddFieldsUsingCode.aspx

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

 

使用CODE创建EDT

转载:http://bbs.mbscn.net/thread-5520-1-1.html

static void AddExtendedDataTtyp(Args _args) { UtilIdElements uie; XInfo XInfo = new XInfo(); TreeNode TNode; TreeNode DNode; str Extname='MyExt'; str Props = "PROPERTIES/n" + " Name #AXUStr35/n" + " Label #/n" + " HelpText #/n" + " FormHelp #/n" + " ArrayLength #1/n" + " DisplayLength #Auto/n" + " ConfigurationKey #/n" + " ButtonImage #Arrow/n" + " Extends #/n" + " DisplayHeight #Auto/n" + " StringSize #35/n" + " Adjustment #Left/n" + " Alignment #Auto/n" + " ChangeCase #Auto/n" + "ENDPROPERTIES/n"; ; select maxof(id) from uie where uie.recordType == UtilElementType::ExtendedType && uie.utilLevel == XInfo.currentAOLayer(); uie.id++; uie.utilLevel = XInfo.currentAOLayer( ); uie.recordType = UtilElementType::ExtendedType; uie.name =Extname ; uie.insert(); DNode = TreeNode::findNode("Data Dictionary//Extended Data Types"); DNode.AOTrefresh(); TNode = TreeNode::findNode("Data Dictionary//Extended Data Types//"+Extname); TNode.sysUtilDelete(); TNode.AOTsetProperties(Props); TNode.AOTsave(); pause; }

你可能感兴趣的:(jobs,alignment,Types)