Sunday, 10 August 2014

Function to get last day of month in AX

Code to find the last day of month in Ax.

static void LastOfMonth(Args _args)
{
   TransDate transDate=today();
   TransDate LastOfMth;
   ;

   //LastOfMth=endmth(mkdate(1,1,2014));//To enter date using business logic.
   LastOfMth=endmth(transDate);

   info(date2str(LastOfMth,123,2,2,2,2,4));
}

Moving object between layers.

There is a very simple way to move objects between layers in AX.
I will try to explain it using an example.

E.g. Moving objects from USR layer to CUS layer.

Follow these steps:
  • Logon to the USR layer.
  • Export the object that is suppose to be moved to CUS layer.
  • Now delete the object in the USR layer.
  • Logon to CUS layer.
  • Import the xpo from the USR layer in the CUS layer.
We have successfully moved the objects from USR layer to CUS layer.All the changes are on USR layer now for this object.

Note: Always start from uppermost layer(USR->SYS) when the changes are on multiple layers.Also it is a good practice to make a project in case of multiple objects.Same steps should be followed on the project.

Thanks

Saturday, 2 August 2014

Ways to deploy SSRS Reports in AX 2012

There are 3 ways to deploy a AX 2012 SSRS report.

1)From Microsoft Dynamics AX(The reporting project needs to be added to AOT first for this option.)

  • Open the Development Workspace.
  • Find the report you have to deploy in SSRS Reports > Reports
  • Right-click and click Deploy Element.

2)From Microsoft Visual Studio
  • In the Solution Explorer right-click on the reporting project that contains the report.
  • Click Deploy.

3)From Microsoft PowerShell
  • This supports deploying multiple reports at a time.
  • For more details see AX 2012 PowerShell

Note: The SSRS report that is created has to be deployed to the reporting server.Till then it is not available for the users.

Wednesday, 30 July 2014

Service could not start in timely fashion when trying to start AX 2012 service

Hello all,

You may encounter this issue when you are trying to begin a AX 2012 service.The service status is "starting" for long time with no response.

Solution:
1)Wait for some time and check if the service begins.Just r-clk -> refresh.

2)If the 1st solution didn't work for 10 mins or so then do the following :

  • r-clk ->properties ->Log-on(Tab) ->this account
  • now browse and enter your login name
  • after that enter the correct password & confirm password.
  • It will say this changes will take effect only when the service restarts.
  • Now try stopping the service if it allows you to do so.
  • After stopping the service, start it again.This time the service should start successfully.(Do wait for the service to start even if it shows the same message again)
  • If the service is unable to stop then restart the system.Let the system load completely and wait for sometime so that the services start.This time the service should get into "started" status very soon.


In case of any doubts please add your queries to the comments.

Thanks 

Tuesday, 29 July 2014

virtualbox save machine state hangs at 100%

This happens when you are trying to save a virtualbox machine with the "Save the machine state" option.

Solution: Remove all the USB devices connected to the machine and then Save the machine state.

Hope this helps!!!

Saturday, 20 April 2013

Restrict duplicate records in AX

In case you have a requirement where you are suppose to restrict the duplicate records.

E.g. :


If in case you have 4 fields.
And you require that any two same record values in the four or less columns should not repeat.

You don't want same record(same combination) to be saved twice.



Column:       A            B          C             D
                 amit      60       India          emp
                  yatish       60       India          emp
                 amit         60       India          emp                ****this record should not be saved


Solution :

1) Make new index to the table.
2) Add the fields that you want to be added to the restricting combination.(Here all 4)
3)Go to properties and set 'AllowDuplicates' to "No".

This will restrict you from saving any duplicate combination in the table.

Note: In case you need only A & B column without repeat then add only A & B fields to index.

Delete all transaction data for a specific company in AX

I have noticed that sometimes we might need to delete all the transaction data for a particular company without altering the configuration data.This is possible in AX.

1)Login into AX in the company for which you want to delete the transaction data.
2)Go to AOT.
3)Open class SysDatabaseTransDelete
4)Run it and Click 'YES' to delete all the transaction data in the current logged in company.

This might take few moments depending on the amount of data.