Map, MapEnumerator, pack/unpack using XML

static void testMapXml(Args _args)
    Map             map = new Map(Types::String, Types::Record);
    MapEnumerator   me;
    CustAccount     custAccount = '1001';
    CustTable       custTable   = CustTable::find(custAccount);
    container       cnt;
    str             xml;
    XmlDocument     xmlDocument;

    if (!map.exists(custAccount))
        map.insert(custAccount, custTable);

    if (map.elements())
        me = map.getEnumerator();
        while (me.moveNext())
            custAccount = me.currentKey();
            custTable   = me.currentValue();

    // pack/unpack Map to/from container
    cnt = map.pack();
    map = Map::create(cnt);

    // pack/unpack Map to/from XML
    xml         = map.xml();
    xmlDocument = XmlDocument::newXml(xml);
    map         = Map::createFromXML(xmlDocument.root() as XmlNode);



About is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags