This is just a quick look at the List object in Dynamics AX. Just played around with it to see what functionality was there and what wasn’t. As you can see I just created a simple list of integers and also one with records from InventTable, if you wan’t to know what types can be placed in the list, check out the baseEnum “Types” in the AOT.
As a bonus I also created a xml file of the list of integers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | static void FO_Lists(Args _args) { List il, il2; ListEnumerator listEnum, listEnum2; AsciiIo file; str filePath; InventTable invent; ; il = new List(Types::Integer); // Add some elements to the list il.addEnd(1); il.addEnd(2); il.addStart(3); print "List ----------"; // Print a description of the list print il.elements(); print il.definitionString(); print il.toString(); // Print List as xml. print il.xml(); // Create an xml file of the list. filePath = "C:\\temp\\list.xml"; file = new AsciiIo(filePath, "W"); file.write (il.xml()); // Get enumerator listEnum = il.getEnumerator(); print "Enumerator ----"; print listEnum.definitionString(); // Loop through enumerator while (listEnum.moveNext()) { // Print value as String. print listEnum.toString(); // Print value as anyType. print listEnum.current(); } // Now a list with records. il2 = new List(Types::Record); while select invent where invent.ItemId == "0001" || invent.ItemId == "0002" { il2.addEnd(invent); } // Get enumerator listEnum2 = il2.getEnumerator(); invent = null; // Get records and print values. while (listEnum2.moveNext()) { invent = listEnum2.current(); print "New record..."; print invent.RecId; print invent.ItemId; } pause; } |
Last 5 posts in Development
- No valid document identified from the entity key - April 9th, 2010
- Using Regular Expressions in Dynamics AX - October 2nd, 2009
- Create class and methods in x++ - December 22nd, 2008
- Simple field lookup in form - October 13th, 2008
- Get your Intercompany CustAccount - September 29th, 2008