Hey guys,
Let's discuss a very interesting code for the simple purpose of filtering objects in a project. I hope we all know about the standard of Ax to filter and import AOT objects in a project. So now we will see how to do it using x++ code:
static void alle_aks_ImportObjectsToProjects(Args _args)
{
sysprojectfilterrunbase varProject;
utilelements aotElements;
varProject = new sysprojectfilterrunbase();
varProject.parmProjectNode(systreenode::createProject('Alle_GST_TaxObejcts'));
varProject.grouping(sysprojectgrouping::AOT);
while select name, utilLevel, RecordType, ParentId from aotElements
where aotElements.utilLevel == UtilEntryLevel::var
&& aotElements.name like 'Tax*'
{
try
{
aotElements.reread();
varProject.doUtilElements(aotElements);
}
catch (exception::Error)
{
throw error('Error');
}
}
varProject.write();
info('Done');
}
Here you can modify the while select query to suit your need i.e. to change the layer or the name filter.
Source: https://mydynamicsax.wordpress.com/2015/03/19/how-to-filter-aot-objects-to-a-project/
Let's discuss a very interesting code for the simple purpose of filtering objects in a project. I hope we all know about the standard of Ax to filter and import AOT objects in a project. So now we will see how to do it using x++ code:
static void alle_aks_ImportObjectsToProjects(Args _args)
{
sysprojectfilterrunbase varProject;
utilelements aotElements;
varProject = new sysprojectfilterrunbase();
varProject.parmProjectNode(systreenode::createProject('Alle_GST_TaxObejcts'));
varProject.grouping(sysprojectgrouping::AOT);
while select name, utilLevel, RecordType, ParentId from aotElements
where aotElements.utilLevel == UtilEntryLevel::var
&& aotElements.name like 'Tax*'
{
try
{
aotElements.reread();
varProject.doUtilElements(aotElements);
}
catch (exception::Error)
{
throw error('Error');
}
}
varProject.write();
info('Done');
}
Here you can modify the while select query to suit your need i.e. to change the layer or the name filter.
Source: https://mydynamicsax.wordpress.com/2015/03/19/how-to-filter-aot-objects-to-a-project/