Extract Microsoft Dynamics AX 2012 Resources to local temp folder

 Create a new job and copy/paste the code below. If you receive warning messages in your infolog you can safely ignore them. Our goal is to acquire the resources, not bother with warnings.



static void ExtractResources(Args _args)
{
    ResourceNode    resourceNode;
    FilePath        filePath;
    #AOT
    Treenode        treeNode;
    Treenode        node;
    str             resourceName;
    int             i, nodeCount;
    treeNode = treenode::findNode(#ResourcesPath);
    nodeCount = treeNode.AOTchildNodeCount();
    node = treeNode.AOTfirstChild();
    for (i = 1; i <= nodeCount; ++i)
    {
     resourceName = node.AOTgetProperty(‘Name’);
     resourceNode = SysResource::getResourceNode(resourceName);
       
     if(resourceNode)
     {
      filePath = SysResource::saveToTempFile(resourceNode);
     }
     node = node.AOTnextSibling();
    }
    info(‘finished extracting the resources.’);
}
    When we navigate to our %TEMP% folder, we see that our code has filled the folder with GIFs, JPGs, PNGs and other useful resource files. Now it’s a simple matter of moving the files you’re looking for and the rest is easy.

    Comments