// Takes a Template Project Name and a Target Project Name
// and automatically creates a new Project from a Template Project.
//
static void CreateNewAOTProjectFromTemplate(Args _args)
{
ProjectNode templateproject;
ProjectNode pretargetproject;
ProjectNode targetproject;
TreeNode sharedProject;
UtilElements utilElement;
str templateprojectname;
str pretargetprojectname;
str targetprojectname = 'AATest';
str pretargetprojectname()
{
return pretargetprojectname;
}
;
// Get the templateprojectname from someplace where the name of a Template project can be found.
// NOTE: You'll need to change this Line and assign your own Template name.
templateprojectname = DPA_Parameters::find().AOTProjectTemplate;
sharedProject = SysTreeNode::getSharedProject();
if (sharedProject.AOTfindChild(targetprojectname))
return;
// Find the Template Project and load it for inspection
templateproject = sharedProject.AOTfindChild(templateprojectname);
if (!templateproject)
return;
templateproject.loadForInspection();
// Duplicate the Template Project using an intermediary ProjectNode
pretargetproject = templateproject.AOTDuplicate();
pretargetproject.AOTsave();
// Get the name of the duplicated project - CopyOf%1 (%1 = whatever the Template name is)
pretargetprojectname = pretargetproject.AOTname();
// Rename the duplicated Project to the desired project name.
// NOTE: I tried other ways, but this is the only way that worked!
// And, it's fast!
ttsbegin;
select firstonly forupdate utilElement
where utilElement.recordType == UtilElementType::SharedProject
&& utilElement.name == pretargetprojectname();
if (utilElement)
{
utilElement.name = targetprojectname;
utilElement.doUpdate();
}
ttscommit;
// Have to refresh the SharedProject Node - Very important!
sharedProject.AOTrefresh();
// Now just get the new project and open it.
targetproject = sharedProject.AOTfindChild(targetprojectname);
targetproject.AOTrun();
}
Subscribe to:
Post Comments (Atom)
How to identify the user that was used to change an object from AOT in AX2012
Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...
-
Combo boxes in Dialogs are added by adding a DialogField object with the type of an enum. The enum is then controlling what items you can pi...
-
This article explains: How to picking list through a job using X++ in Dynamics AX. Applied on: Dynamics AX 2009 SP1 Create a job a...
-
A while ago I had the need to translate labels, I was creating eMail bodys while using SysMailer and wanted to use different languages for d...
No comments:
Post a Comment