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

AX2012 R3: DIXF Could not load assembly error

While working on DIXF there can be scenario where you may face errors where assemblies are not able to load properly. Like below:

"Could not load file or assembly 'microsoft.dynamics.ax.framework.tools.dmf.previewgrid.dll'"

In this case you can use 2 options:

1. You can reinstall DIXF Client.
2. You can copy the dll file mentioned in the error from one AOS where it's working properly and paste it to the AOS where the error is coming. The file location is "C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin".

SSIS 2012: Access is denied error

While connecting to SSIS in SSMS, you may face an error of "Access is denied". It can be resolved by following the below steps:
  1. If the user is not a member of the local Administrators group, add the user to the Distributed COM Users group. You can do this in the Computer Management MMC snap-in accessed from the Administrative Toolsmenu.
  2. Open Control Panel, double-click Administrative Tools, and then double-click Component Services to start the Component Services MMC snap-in.
  3. Expand the Component Services node in the left pane of the console. Expand the Computers node, expandMy Computer, and then click the DCOM Config node.
  4. Select the DCOM Config node, and then select SQL Server Integration Services 11.0 in the list of applications that can be configured.
  5. Right-click on SQL Server Integration Services 11.0 and select Properties.
  6. In the SQL Server Integration Services 11.0 Properties dialog box, select the Security tab.
  7. Under Launch and Activation Permissions, select Customize, then click Edit to open the Launch Permissiondialog box.
  8. In the Launch Permission dialog box, add or delete users, and assign the appropriate permissions to the appropriate users and groups. The available permissions are Local Launch, Remote Launch, Local Activation, and Remote Activation. The Launch rights grant or deny permission to start and stop the service; the Activation rights grant or deny permission to connect to the service.
  9. Click OK to close the dialog box.
  10. Under Access Permissions, repeat steps 7 and 8 to assign the appropriate permissions to the appropriate users and groups.
  11. Close the MMC snap-in.
  12. Restart the Integration Services service.
Reference: https://msdn.microsoft.com/en-us/library/aa337083.aspx

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'