Dynamics AX Blog - Dynamics AX 2009 - Posts from 2014

RSS-Feed of this version
Example of how to use RecordInsertListA short code example how to can create records in a table very performant way using RecordInsertList. Who does not know RecordInsertList, can learn more about here. static void HowToUseRecordInsertList(Args _args) { DMOPerfTest DMOPerfTest; RecordInsertList RecordInsertList; Counter c; FromTime fromTime = timeNow(); RecordInsertList = new RecordInsertList(tableNum(DMOPerfTest)); for (c=1;c<=10000;c++) { DMOPerfTest.clear(); DMOPerfTest.AccountNum = int2str(c); if(DMOPerfTest.validateWrite()) { RecordInsertList.add(DMOPerfTest); } } RecordInsertList.insertDatabase(); info(strFmt("Total time consumed: %1", timeConsumed(fromTime, timeNow()))); } |
Add object nodes to a shared project through codeFind below a short example, how to add object nodes to a shared project through code. static void AddNodeToSharedProject(Args _args)
{ projectNode projectNode; TreeNode treeNode; #AOT #AOTExport projectNode = infolog.projectRootNode(); projectNode = projectNode.AOTfindChild(#expProjectShared); projectNode = projectNode.AOTfindChild('MyProject'); // Add objects treenode = TreeNode::findNode(#TablesPath+'\\'+tableid2name(tablenum(CustGroup))); projectNode.addNode(treenode); treenode = TreeNode::findNode(#TablesPath+'\\'+tableid2name(tablenum(VendGroup))); projectNode.addNode(treenode); treenode = TreeNode::findNode(#ClassesPath+'\\'+classStr(PriceDisc)); projectNode.addNode(treenode); } The so modified Project will look like this: |
Loop through values of a Base enumSysDictEnum SysDictEnum = new SysDictEnum(enumNum(SalesStatus)); int i; for (i=0;i<SysDictEnum.values();i++) { info(SysDictEnum.index2Label(i)); } |
SQL-Error occurs when opening or synchronizing a tableIf the follwoing error occurs, when opening or synchronizing a - mostly new created - table
the reason could be, that the table contains a field, whose name is a "reserved word" from the database, For example, you cannot use Primary as field Name. |
Use macro within a SELECT statementThe SELECT-Statement in the example lists only active BOM items (Table BOM) on (active using the fields FromDate and ToDate). If the second parameter of the macro is empty (zero date ()), so all BOM items are listed. static void useMacroInSelectStatement(Args _args) { bom bom; date emptyDate; // parameters: %1 = table instance, %2 date, %3 empty date value #localmacro.bomDateFilter && ( %2 == dateNull() || ( ((%1.FromDate <= %2) && (%1.ToDate >= %2)) || ((%1.FromDate == %3) && (%1.ToDate == %3)) || ((%1.FromDate <= %2) && (%1.ToDate == %3)) || ((%1.FromDate == %3) && (%1.ToDate >= %2)) )) #endMacro ; while select bom where bom.ItemId == '123' #bomDateFilter(bom, systemDateGet(), emptyDate) { info(bom.bomid); } } |
Which fields are shown in an auto-generated lookup?I was asked this question recently and was not able to answer. But i still knew that i had seen a page where this is explained in detail. But i knew neither find it manually nor using various search engines. But in old documents of mine i found the source then, the trick to find it using search engines, is using the old name of Microsoft Dynamics AX - Axapta to look for it! Do this, you will quickly find following page: |
|
|
|
|
|
|
If you want to use a particular dimension as a dialog field in Dynamics AX 2009 (or earlier versions), you can create your own Extended Data Type (derived from Criterias) as described below. The decisive factors are the relations of this EDT.
In the example, the cost center is to be offered as a dialog field.
The example code was taken from a class which extends runBase.