Hello guys,
I'm starting to learn how to create XML for D365.
I got this tutorial, but it looks like it is for AX2012, And here is what I already did :
class My_SimpleXMLCreate
{
///
/// Runs the class with the specified arguments.
///
/// The specified arguments.
public static void main(Args _args)
{
XmlDocument xdoc;
XmlElement xElement;
XmlElement xTable, xNodeAccount, xNodeName;
MainAccount mainAccount;
#define.filename(@'C:\Temp\accounts.xml');
xdoc = XmlDocument::newBlank();
xElement =xdoc.createElement('xml');
xdoc.appendChild(xElement);
while select RecId, mainAccountId, Name from mainAccount
{
xTable = xdoc.createElement(tableStr(MainAccount));
xTable.setAttribute(fieldStr(MainAccount, RecId), int642Str(mainAccount.RecId));
xElement.appendChild(xTable);
xNodeAccount = xdoc.createElement(fieldStr(MainAccount, MainAccountId));
xNodeAccount.appendChild(xdoc.createTextNode(MainAccount.MainAccountId));
xTable.appendChild(xNodeAccount);
xNodeName = xdoc.createElement(fieldStr(MainAccount, Name));
xNodeName.appendChild(xdoc.createTextNode(mainAccount.Name));
xTable.appendChild(xNodeName);
}
xdoc.save(#filename);
Info(strFmt("File %1 created", #filename));
}
}
So 1st of all, after Build, I have this error and red line on the function name (public static void main)
Severity Code Description Project File Line Suppression State
Error A reference to 'Dynamics.AX.SourceDocumentationTypes, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is required to compile this module. MyPro2 (ISV) [Fleet Management K:\AosService\PackagesLocalDirectory\bin\XppSource\FleetManagement\AxClass_My_SimpleXMLCreate.xpp 7
2nd, is because now on the Cloud, I don't think it is 'cool' to save it in C:\Temp, what would be the preferred way now ?
Lastly, how to improve this code to be more suitable in D365 environment ?
Thanks.