Monday, 3 August 2015

Export a shared/private project through x++ code in Microsoft Dynamics AX 2012

static void exportingtoxpos(Args _args)
{
TreeNode treeNode;
FileIoPermission perm;
#define.ExportFile(@"D:\TestProject.xpo")
#define.ExportMode("w")

perm = new FileIoPermission(#ExportFile, #ExportMode);
if (perm == null)
  {
        return;
  }

perm.assert();

treeNode = TreeNode::findNode(@"\Projects\private\SSRSReports"); //path of project either private                                                                                                                     or shared and project name
if (treeNode != null)
  {
      // BP deviation documented.
      treeNode.treeNodeExport(#ExportFile);
  }

CodeAccessPermission::revertAssert();
}

2 comments: