Wednesday, 29 October 2014

SysDatabaseTransDelete Delete transactions in Dynamics AX 2012



If it’s needed to delete all transactional data (such as PO’s SO’s, Posted invoices, Journals etc.),  while you want to save the master data (Customers , Vendors list etc.) and parameters/setup as well, minor modification is needed in class SysDatabaseTransDelete

Open this class SysDatabaseTransDelete and modify one of its methods named as handleTable as shown below

if (sysDictTable.dataPrCompany())
        {
            switch(tableGroup)
            {
                case TableGroup::Transaction:
                case TableGroup::WorksheetHeader:
                case TableGroup::WorksheetLine:
                case TableGroup::TransactionHeader://Customization
                case TableGroup::TransactionLine: //Customization
                    this.handleTransTable(sysDictTable);
                    break;
                default:
                    this.handleNonTransTable(sysDictTable);
                    break;
            }
        }
        else
        {
            // Handle global tables to be deleted
            switch(tableGroup)
            {
                case TableGroup::Transaction:
                case TableGroup::TransactionHeader :
                case TableGroup::WorksheetHeader:
                case TableGroup::WorksheetLine:
                case TableGroup::TransactionHeader://Customization
                case TableGroup::TransactionLine://Customization
                    this.handleGlobalTransTable(sysDictTable);
                    break;
                default:
                    break;
            }
        }


After you run this class in each company where it’s needed to delete data, you need to do 1 more step as under.
Go to General Ledger>> Setup >> Financial Dimensions >> Financial Dimension sets
Select each set one by one and click two buttons in a sequence i.e. 1) Rebuild Balances 2) Update Balances  

 go and chweck your trial balance now.

1 comment:

  1. Hope this would work with AX 2012 CU6 as well?....please confirm.

    Thanks
    Axian

    ReplyDelete