Showing posts with label company. Show all posts
Showing posts with label company. Show all posts

Friday, December 11, 2015

Cross-Company-External record context

I faced a situation where I had to convert a listpage to cross company in EP. So I changed the query and redeployed. Pretty easy stuff. But then on clicking the record it opens a web control for approval and same thing happens with a button in the toolbar above. So in the case of cross company the web control was getting displayed blank as it wasn't getting the record context.

So I was able to handle the toolbar button by changing it's property "External Record Context" but couldn't handle the record link (HyperLinkButton). I tried getting the record context using IAxaptaAdapter but it didn't seem to work. :(


Wednesday, September 9, 2015

Reset Number sequence Ax2012

Whenever you need to reset the number sequence in AX2012 you can use the below job code. You just need to pass the company name for which you want to reset.

static void resetNumSeq(Args _args)
{
    NumberSequenceTable numseqtab;
    info(curext());
    changecompany ('test')
    {
        ttsbegin;
        while select forupdate numseqtab
        {
            numseqtab.NextRec = numseqtab.Lowest;
            numseqtab.update();
        }
        ttscommit;
    }
}

Monday, August 31, 2015

Delete all transactions Ax2012

There is a class named "SysDatabaseTransDelete" in Axapta which can be used to delete all the transactions from your Ax Db but will not delete the base setups. In that case we can use the same DB as Production Db.
NOTE: It works perfectly with Ax2012 CU3 and above as it is now updated for new DB structure. Otherwise you may face issues with General Journal/Trial balance data.
It deletes all data from tables in the Transaction, WorksheetHeader and WorksheetLine table groups plus the following tables...
       SalesTable
       PurchTable
       WMSPallet
       CustInterestJour
       CustCollectionLetterJour
       ProjControlPeriodTable
       ProjInvoiceJour
       ProjJournalTable
       PdsRebateTable
       PdsBatchAttributes
You can run it from the AOT by right clicking on the SysDatabaseTransDelete class node and selecting "open" - this isn't the sort of thing you would want to put on a menu anywhere.
Here is a job for the same:
static void deleteTransactions(Args _args)
{
SysDatabaseTransDelete delete;
;
delete = new SysDatabaseTransDelete();
delete.run();
}

Friday, August 21, 2015

Delete company in AX2012 using SQL

Sometimes we are not able to delete company from AX due to existing transactions then SQL comes to the rescue and does the job beautifully.

There is a Stored Procedure in "master" database named "sp_MSforeachtable". Use the below commands:


This will delete all the transactions from all the tables related to that particular company:


EXEC sp_MSforeachtable 'delete from ? where ?.DataAreaID = "CEU"'


This will delete the company name from the company list in AX:


DELETE FROM DATAAREA WHERE DATAAREA.ID 'CEU'