blog for Dynamics Axapta

Archive for February, 2017

Export your AOT Custom Objects Automatically

Hi,

Here I have posted a job to export all our newly created projects / jobs / any AOT objects as XPO automatically.

static void VAS_ExportXPO(Args _args)
{
#AOT

FileIoPermission perm;
ProjectListNode projectListNode;
ProjectNode projectTreeNode;
TreeNode treeNode, jobTreeNode;
TreeNodeIterator iterator, jobIterator;
str projName;
str exportProjName = ‘VAS_’;
str jobName;
str exportJobName = ‘VAS_’;
int noOfProjects;
int noOfJobs;
str folderpathProj, folderpathJobs;

#define.ExportMode(“w”)

;
folderpathProj = strfmt(@’C:\Vasanth Arivali\XPO Backup\%1\SharedProject’, date2str(today(), 321, 2, 3, 2, 3, 4));
folderpathJobs = strfmt(@’C:\Vasanth Arivali\XPO Backup\%1\Jobs’, date2str(today(), 321, 2, 3, 2, 3, 4));
WINAPI::createDirectoryPath(folderpathProj);
WINAPI::createDirectoryPath(folderpathJobs);

perm = new FileIoPermission(folderpathProj, #ExportMode);
if (perm == null)
{
return;
}
perm.assert();

projectListNode = SysTreeNode::getSharedProject();
iterator = projectListNode.AOTiterator();

treeNode = iterator.next();
while (treeNode)
{
projName = treeNode.AOTname();
if ( exportProjName == substr(projName, 1, 8))
{
// BP deviation documented.
treeNode.treeNodeExport(folderpathProj + ‘\\SharedProject_’ + projName + “.xpo”);
noOfProjects++;
}
treeNode = iterator.next();

}

jobIterator = TreeNode::findNode(@’\Jobs’).AOTiterator();
jobTreeNode = jobIterator.next();
while (jobTreeNode)
{
jobName = jobTreeNode.AOTname();
if ( exportJobName == substr(jobName, 1, 8))
{
// BP deviation documented.
jobTreeNode.treeNodeExport(folderpathJobs + ‘\\Job_’ + jobName + “.xpo”);
noOfJobs++;
}
jobTreeNode = jobIterator.next();

}

CodeAccessPermission::revertAssert();

if (noOfProjects > 0)
info(strfmt(‘%1 Projects exported sucessfully’, noOfProjects));
if (noOfJobs > 0)
info(strfmt(‘%1 Jobs exported sucessfully’, noOfJobs));
}

Hope this will help you guys.

// Vasanth Arivali

Auto comments on our customization codes by Editor Script Class

Hi Friends,

Here I have posted the code for auto comments by amending Editor Scripts class.

Adding auto script CODE comments
// Changes: XYZ to your intial name
public void addCommentsCODE(Editor _e)
{
int startLine = _e.selectionStartLine();
int endLine = _e.selectionEndLine();
str prefixCompany = “CONTOSO”;
str developerID;
str tagStart;
str tagEnd;
;

switch (curUserId())
{
case “vasan”: developerID = “Vasanth”;
break;
case “steve”: developerID = “Steven”;
break;
default:
developerID = “XYZ”;
}

tagStart = strFmt(“//–> %1 modified on %2 %3 by %4: %5 ~ mod description\n”,
enum2str(currentAOLayer()),
date2str(today(), 321, 2, 3, 3, 3, 4), time2str(timeNow(), 1, 1),
prefixCompany,
developerID
);
tagEnd = strfmt(“//<– by %1\n”, prefixCompany);

_e.gotoCol(1);
_e.unmark();

_e.gotoLine(startLine);
_e.insertLines(tagStart);

_e.gotoLine(endLine+2);
_e.insertLines(tagEnd);
}

Once done, got to code window, right click -> scripts -> you find the method created. Hope it will help you.

// Vasanth Arivali