In this post let’s explore creating XML using X++ code in Dynamics AX.

The following example shows how to create and write data to an XML file by using the XmlDocument, XmlElement, and XmlWriter classes. It loops through all of the records in the CarTable and find all the fields in the table automatically by using the DictTable and DictField classes.

{% highlight csharp %} static void WriteXml(Args _args) {

XmlDocument xmlDoc;
XmlElement xmlRoot;
XmlElement xmlField;
XmlElement xmlRecord;
XMLWriter xmlWriter;

CarTable carTable;
DictTable dTable = new DictTable(tablenum(CarTable));
DictField dField;
int i, fieldId;
str value;


// Create a new object of the XmlDocument class
xmlDoc = XmlDocument::newBlank();

// Create the root node
xmlRoot = xmlDoc.createElement(#CarRootNode);

// Loop through all the records in the carTable
while select carTable
    // Create a XmlElement (record) to hold the
    // contents of the current record.
    xmlRecord = xmlDoc.createElement(#CarRecords);
    // Loop through all the fields in the record

    for (i=1; i<=dTable.fieldCnt(); i++)
        // Get the fieldId from the field-count
        fieldId = dTable.fieldCnt2Id(i);
        // Find the DictField object that matches the fieldId
        dField = dTable.fieldObject(fieldId);
        // Skip system fields
        if (dField.isSystem())

        // Create a new XmlElement (field) and
        // have the name equal to the name of the
        // dictField
        xmlField = xmlDoc.createElement(;
        // Convert values to string. I have just added
        // a couple of conversion as an example.
        // Use tableName.(fieldId) instead of fieldname
        // to get the content of the field.
        switch (dField.baseType())
            case Types::Int64 :
                value = int642str(carTable.(fieldId));
            case Types::Integer :
                value = int2str(carTable.(fieldId));
            default :
                value = carTable.(fieldId);

        // Set the innerText of the XmlElement (field)
        // to the value from the table
        // Append the field as a child node to the record
     // Add the record as a child node to the root
// Add the root to the XmlDocument
// Create a new object of the XmlWriter class
// in order to be able to write the xml to a file
xmlWriter = XMLWriter::newFile(@"c:tempcars.xml");
// Write the content of the XmlDocument to the
// file as specified by the XmlWriter

} {% endhighlight %}

The answer is that there is no difference, the difference is a conceptual one rather than a functional or a technical one. So I think you will make a better choice for your scenario base on functional side. Display Menu itemThis folder is used to contain menu items that reference runnable application objects that primarily present forms, ddialog and so on, to the user. May be this forms, dialog called from another forms.
The model store is the portion of the Microsoft Dynamics AX database where all Microsoft Dynamics AX application elements are stored, including customization. The model store replaces the AOD (application object definition) files used in previous releases of Microsoft Dynamics AX (I mean from 4.0 to 2009). Layer and model information are integral parts of the store. The AOS has access to the model store, handles layer-flattening, and provides model data to all the Microsoft Dynamics AX sub-systems, such as form- and report-rendering and X++ code.

Understanding the internal architecture of Microsoft Dynamics AX 2012 can help you make decision when planning and developing a Microsoft Dynamics AX 2012 system. Here are some pointers on DAX 2012 architecture primarily for DAX 2012 architects & solution developers. This topic provides a high-level overview of the system architecture of Microsoft Dynamics AX.

This diagram provides a high-level over of a Microsoft Dynamics AX 2012 system with all components installed, and describes how communications flow between the components.


I don’t know exactly how I ended up where I am. I mean, programming, and lovin’ it. Even if I’m not so good. I’ve heard a thousand of guys telling stories like: “When I was twelve my parents bought me my first computer and I started learning on my own.” or “I won a programming contest when I was in highschool”. Great. Well done. I’ve never noticed about what coding was until I was eighteen, when I had to decide what to study at the University.
Base on JournalId on LedgerJournalTable you can use code below to post the transactions {% highlight csharp %} //Contract class [ DataMemberAttribute(‘gJournalId’), SysOperationDisplayOrderAttribute(‘1’) ] public LedgerJournalId parmJournalNum(LedgerJournalId _journalId = gJournalId) { gJournalId = _journalId; return gJournalId; } //Processing class [SysEntryPointAttribute] public void process(MAV_PostCustPaymentJourContract _contract) { LedgerJournalTable ledgerJournalTable; LedgerJournalCheckPost postCustPaymentJournal; ledgerJournalTable = LedgerJournalTable::find(_contract.parmJournalNum()); if (ledgerJournalTable) { postCustPaymentJournal = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable, NoYes::Yes);; } } {% endhighlight %}