web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Storing and retrieving an XML in Resource node in Dynamics Ax

Community Member Profile Picture Community Member

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.

Comments

*This post is locked for comments