Integration Manager VBA Script To Create XML Output

Microsoft Dynamics GPWe have a client who will be loading payables transactions into Microsoft Dynamics GP and need secondary postings created into the General Ledgers of other company databases. The idea is to use the AfterDocument script to create and submit an eConnect document, which is in XML format.

The below code is a small proof of concept which creates an XML file with child and parent nodes and saves it to the T:\:

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales (CC BY-NC-SA 2.0 UK).
*/
Set xmlDoc = CreateObject("Microsoft.XMLDOM")

Set objRoot = xmlDoc.createElement("RootElement")
xmlDoc.appendChild objRoot

Set objRecord = xmlDoc.createElement("SubLevel1")
objRoot.appendChild objRecord

Set objName = xmlDoc.createElement("Element1")
objName.Text = "AAAAAAA"
objRecord.appendChild objName

Set objDate = xmlDoc.createElement("Element2")
objDate.Text = "BBBBBBB"
objRecord.appendChild objDate

Set objIntro = xmlDoc.createProcessingInstruction ("xml","version='1.0'")
xmlDoc.insertBefore objIntro,xmlDoc.childNodes(0)

xmlDoc.Save "T:\Test.xml"