29.08.2008, 21:10 | #1 |
Участник
|
axaptapedia: Create New AOT Project From Template
Источник: http://www.axaptapedia.com/Create_Ne..._From_Template
============== Summary: If you want to automatically create a project from a Template Project (An Empty Project with just the AOT Structure for example), then you can use this code as a helpful guideline. X++: // // 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(); }
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
За это сообщение автора поблагодарили: alex55 (1). |
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|