Tuesday, January 8, 2013

Start Debugging in AX 2012 - for non-developers

In order to start debugging the Dynamics AX code first you need to enable debugging for the current user. You can enable the debugging for the current user by setting the Debug mode to "When Breakpoint" under "File/Tools/Options/Development/Debug" tab.


If you don't know where to start debugging an issue that throws an Infolog message, you can put a breakpoint to Info:add class.This will make the process stop for debugging for every infolog message.


Then in the debugger, when the process stops you can traverse the callstack in order to find the underlying issue.



Where is the user information kept in Dynamics AX?

The name of the table that keeps the user information in Dynamics AX is "UserInfo". But you cannot access this table under "AOT/Data Dictionary/Tables" like any other database tables in AX.

You can reach this table and browse it under "AOT/System Documentation/Tables". 


In order to browse the table right-click and use "Table Browser":

















How to debug the X++ code that is compiled to CIL?

One of the neat features of Dynamics AX 2012 is that it provides a way to compile X++ code to IL which then can be consumed by Microsoft .NET framework and  in return enhances the performance. But this brings some complexity to the issue identification and debugging efforts. In Dynamics AX 2012 client, if you receive an Infolog message which is not very meaningful and the double click on that message does not take you to any code, it is very likely that the code that you are running during your process is compiled into IL using this new feature. One way to get around this issue and to debug the System Operations Framework is to make the following change on runServiceOperation function of SysOperationRPCFrameworkService  class:


public static container runServiceOperation(ClassId controllerClassId, container packedController)
{
    // Use the runas API to transition to a CLR session
    new XppILExecutePermission().assert();
    
    // Disable this piece of Code - AK
    /*return SysDictClass::invokeStaticMethodIL(classStr(SysOperationServiceController),
                                        staticMethodStr(SysOperationServiceController, runServiceOperation),
                                        [controllerClassId, packedController]);*/
  
    // instead make this call - AK
    return SysOperationServiceController::runServiceOperation([controllerClassId, packedController]); 
}

After making this change, you will be able to double click the Infolog message and put a breakpoint and trace the call stack to find the underlying issue that causes the Infolog message.

X++ Development Notes for Non-Developers 01 - Empty Date Values

If you need to set a date field to an empty date or if you need to check whether a date field is empty or not, you can use Global::datenull() function which basically returns the date "01/01/1900". Here is a simple example

if (mydatefield == datenull())

// You don't need to specify Global class name to access Global class functions


Initial Step for Tracking an Unknown Enterprise Portal Issue

If you are having an issue on Enterprise Portal for Dynamics AX 2012 with no warning/error messages and wonder how you can start tracking this issue, here is the place that you can find the log files for SharePoint.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\$VERSION\LOGS 

In addition, you can also check the event logs on the SharePoint Server which you can locate at

Server manager | Diagnostic | Event viewer. 

Right Click on Application and do Save All Events As 

to save the log file.