Quantcast
Channel: Dynamics NAVAX
Viewing all articles
Browse latest Browse all 219

Delete Private AOT projects in AX 2012

$
0
0

This is a common problem since the old days. People leave projects in their private project and no one can get to it to clean it up.

In pre AX2012, it was a matter of selecting the utilElements and calling the AOTDelete method. I won’t go through it here.

In AX2012, it is all maintained in the model store.

Let see it in pictures.

Below are the projects you want to delete.

Proj2013-01-30_1514

You can see them in the SysModelElement table. It is in the system tables section.

PrivateProj2013-01-30_1513

I wrote a job to loop through and delete them. I had to

Code:
staticvoid deleteAllProjectObjects3(Args _args)
{
/*
msdn.microsoft.com/en-us/library/bb190038(v=ax.10).aspx
*/

SysModelElement sysModelElement;
ProjectNode privatePn;
ProjectNode pn;
utilElementName shortName;
int len;
str preFix;

// Navigate to the Private projects folder.
privatePn = infolog.projectRootNode().AOTfindChild("Private");

preFix = curuserid()+'_';
len = strlen(preFix);


while select sysModelElement
where sysModelElement.ElementType == 38
//&& sysModelElementName like "*TestProj*"
{
// remove <userId>_ from the _projectName to get the name used in the Projects tree for a private project
if (substr(sysModelElement.Name, 1, len) == preFix)
{
shortName = strdel(sysModelElement.Name, 1, len);
}

// Get a reference to the project.
pn = privatePn.AOTfindChild(shortName);

pn.AOTdelete();
}
}



Disclaimer:


Use at your own discretion. No guarantees here.


Viewing all articles
Browse latest Browse all 219

Trending Articles