Wednesday, April 4, 2018

Delete AUC for all users

Hey Guys!

Today I have got a small but interesting thing in Ax. We had a situation wherein space of C drive was reaching the alarming level of the Ax-client server (from where all users access Ax). I ran the tool WizTree which displays the analysis of a drive as per the space occupancy. It showed that the maximum amount of space was taken by the AppData folder and I knew what needs to be done next.

The problem was auc files had accumulated for all the users which were summed up to almost 30Gb. So, I decided to delete them but the challenge was how to delete it for all the users at once. So I took help from my master (yes, it's Google) and created a batch which will traverse through all the users AppData folder and delete the auc/kti files.

1. Open Notepad.
2. Paste the below commands there:

for /D %D in ("C:\USERS\*") do del "%~fD\AppData\Local\*.auc"
for /D %D in ("C:\USERS\*") do del "%~fD\AppData\Local\*.kti"
pause

3. Save the notepad as .bat file.


4. Run the batch file and it will delete all the auc/kti files for all the users.

Credits: http://blog.bhsolutions.com/index.php/2014/05/dynamics-ax-2012-spring-cleaning-app-data/
https://stackoverflow.com/questions/34019989/batch-file-copy-all-users-profile-app-data

Tuesday, January 9, 2018

Filter AOT objects using X++ in Ax2012

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/