Storing and retrieving an XML in Resource node in Dynamics Ax
Views (9901)
Resource node in Dynamics Ax can be used to store images, xml, Gif files. In this article let’s see how to store and retrieve an Xml file in resource node through X++.
Read the xml from Resource node
private void initializeResourceNode()
{
Xml loadXML;
ResourceNode gResNode;
XmlDocument gXml;
;
//load element to resource node
gResNode = TreeNode::findNode(@'\Resources\SysVersionControlSystemMorphXDefFile');
//load xml to co
[loadXML] = SysResource::getResourceNodeData(gResNode);
gxml = XMLDocument::newXml(loadXML);
}
Saving the Xml after modifying contents
private void packResourceNode()
{
TextBuffer textBUffer;
BinData binData;
ContainerClass containerClass;
;
//Load Xml to text buffer
textBuffer = new TextBuffer();
textBuffer.setText(gXml.xml());
//Move it to container
containerClass = new ContainerClass([[SysResourceType::XMLDoc],new ContainerClass([textBuffer.getText()]).toBlob()]);
//Store container to bin data
binData = new BinData();
binData.setData(containerClass.toBlob());
//Set data in resource node
gResNode.AOTSetData(binData);
gResNode.AOTsave();
}
This was originally posted here.

Like
Report
*This post is locked for comments