Due to the level of interest that I received on my last post, I’ve decided to go ahead and release this version of the “Objects not in Version Control” script. I’ve cleaned up the code and added some improvements that have drastically improved performance, but it still does not compare to the efficiency of the Model Store in AX 2012.
Please note that the following script is nowhere near as quick as the one posted for AX 2012 due to the performance issues associated with the UtilElement views in older versions of AX.
static void ObjectsNotInVCS(Args _args)
{
SysVersionControlSystem vcsSys;
SysVersionControllable controlable;
Set parsed = new Set(Types::String);
UtilEntryLevel curLayer = currentAOLayer();
UtilElements child, parent;
xRefPath nodePath;
TreeNode pNode;
;
//If version control is not enabled, no need to continue
vcsSys = versionControl.parmSysVersionControlSystem();
if(!vcsSys)
{
info("Version control not enabled");
return;
}
//Iterate through all item in the current layer
// You can add additional filtering here to reduce
// the number of objects parsed.
while select child
where child.utilLevel == curLayer
{
//Get the parent node of the current object
parent = xUtilElements::parentElement(child);
pNode = SysTreeNode::findNodeInLayer(
parent.recordType, parent.name, 0, curLayer);
if(!pNode)
continue;
if(parsed.in(pNode.treeNodePath()))
continue;
parsed.add(pNode.treeNodePath());
controlable = SysTreeNode::newTreeNode(pNode);
if(!controlable)
continue;
if(vcsSys.allowCreate(controlable))
{
info(strfmt("%1",pNode.treeNodePath()));
}
parsed.add(pNode.treeNodePath());
}
}
If you have any tips or tricks for improving the performance of this script, please feel free to add a comment.