Bojensen Blogs

How to loop through a Map in AX 2012


Map iim = new Map(Types::Integer, Types::Class);
MapIterator it;
// Add some elements into the map
iim.insert(1, new query());
iim.insert(2, new query());
iim.insert(4, new query());

// Create a map
iterator it = new MapIterator (iim);

// Print "[int -> class] iterator"
print it.definitionString();

// Go on for as long as elements are found in the map
while (it.more())
  // Print each key (1, 2, 4)
  print it.key();

  // Print text representation of each value
  print it.value().toString();

  // Fetch next element in map;

MapIterator Class [AX 2012]

Comments are closed.