Wednesday 2 October 2013

Physical inventory reports slow


We investigated the situation where the physical inventory reports were running slower and slower. Months ago the reports only took a couple of minutes to run, now it was over an hour. Users tended to kill the sessions which caused the report to run even slower. 

The report uses two tables in AX to build up the report data:

  • InventSumDateTable
  • InventSumDateTrans
When the report is started, the data in the tables is filled and after completing the generation of the report, the tables are emptied. However, when someone kills the sessions which is generating the report, the data in the tables isn't deleted and causes the report to generate slower on the next run. 

When you have performance issues, check if these tables contains records and if so, delete them. After we cleaned up the data, the report ran within minutes again. 

Tuesday 1 October 2013

Reset number sequences Dynamics AX

When you create a new company and copy the setup / parameter tables from another company, you'll want to reset the number sequences.

static void JLH_ResetNumberSequences(Args _args)
{
    NumberSequenceTable         numberSequenceTable;
    NumberSequenceList            numberSequenceList;
    ;

    // We want to be very sure that we are in the correct company :-)

    if (curExt() == '130')
    {
        ttsbegin;

        // First reset all number sequences

        while select forupdate numberSequenceTable
        {
            numberSequenceTable.NextRec = numberSequenceTable.Lowest;
            numberSequenceTable.doUpdate();
        }

        // Then delete exiting records in the lists

        delete_from numberSequenceList;

        ttscommit;
        info("Number sequences have been reset");
    }
    else
    info(strfmt("Number sequence of company %1 should not be reset", curExt()));

}