Category Archives: Batch

To Debug Ax Service Operations Framework

To debug the Dynamics Ax, service operations (SysOperationService) framework, change the following method as follows…

Classes –> SysOperationRPCFrameworkService –>runServiceOperation


/*return SysDictClass::invokeStaticMethodIL(classStr(SysOperationServiceController),

                                        staticMethodStr(SysOperationServiceController, runServiceOperation),

                                        [controllerClassId, packedController]);*/

return SysOperationServiceController::runServiceOperation([controllerClassId, packedController]);

Credit :



Tags: , , ,

Debugging Batch Jobs of Microsoft Dynamics AX 2012 in Visual Studio

Recently I came across a requirement for that I need to debug the Batch Jobs but after CIL Generation we cannot debug the logic inside the Batch job. But there is a way to debug the Batch Jobs . Follow the below listed steps to debug the Batch Jobs.

First we need to do or make sure that the following listed settings..

Settings in Microsoft Dynamics AX Server Configuration Utility:

1.   Go to Start à Administrative Tools à Microsoft Dynamics AX 2012 Server Configuration

2.   On the AOS machine turn debugging on in the server configuration utility by marking following      two checkboxes

a.  “Enable breakpoints to debug X++ code running on this server”

b.  “Enable global breakpoints”.

3.   Click yes to restart the AOS.

Settings in Microsoft Dynamics AX Client Configuration Utility:


1.  Go to Start Administrative Tools à Microsoft Dynamics AX 2012 Configuration

2. On the client machine turn debugging on in the client configuration utility for the Business                   Connector.You can do this in the configuration utility by setting the Configuration Target drop down to Business Connector (non-interactive use only).

Set Debugging Mode in AX client:

 1. In AX go to Tools > Options > Development tab. Select “When Breakpoint” in debugging mode option.

Changes in MS Visual Studio:

Do the following settings in .Net application. But these are not mandatory but recommended.

1. Go to Tools à Options.

2. Go to Debugging à General. Ensure the “Enable break point filter” option is selected.

3. Go to symbols in the same window.

4. Click on new folder icon on top right of the window.

Enter the path where all the Microsoft symbols stored, typically the path would be as shown below.

C:Program FilesMicrosoft Dynamics AX60ServerMicrosoftDynamicsAXbinXppIL

Enter the same path in the Cache symbols in the directory. The window would be as shown below.

Click on OK.

Before debugging the Batch Jobs do the following settings in visual studio:

1. Open another instance of Visual Studio,

2.Go to View Menu Bar and click Application Explorer,put the break points in the appropriate classes.

3.Open AX Debugger instance

4.Go to Tools Click on Attach Process.

5. A window will be open with all installed programs. Select AX32serv.exe,AXDebug.exe and Ax32.exe corresponding to your user name as the process to debug and click on Attach.


Note : We should not close this instance of Visual Studio where you did the attach process,just minimize it and keep going on…

6.Add your batch Job in Dynamics AX and wait for visual studio debugger instance.

7. Switch to the visual studio instance and try to debug now.

Start the debugging in Visual studio application then the debugger will automatically switched to batch Job classes where you have kept the break point in another instance which you have minimized.

Happy Daxing   Smile


Tags: , , , , ,

How to setup Axapta batch server running as user defined windows service-client batch

Batch processing allows you to run a job, that requires a large amount of computer power, on another, faster computer. Batch jobs, once they are activated to run, are sent to a batch list, where they are queued, and will eventually be ran. This allows you to have jobs run without tying up your computer’s power, meaning that you can continue to work while your job is being run. But, you should have in mind that it’s not enough to schedule your job in Axapta using a Batch tab on the form. Even though your job will be put into a queue, it will not be executed until Axapta is started as a batch executer (processing instance). In order to have this kind of Axapta running you can simply start one more instance of Axapta client and go to Basic -> Periodic -> Batch -> Processing

specify there batch group which this instance should take care of and that’s basically it. But, having one more instance of Axapta running will make you a trouble when for example server was suddenly restarted. In order to start an Axapta client as a batch server instance you can specify special command line parameter using -startupcmd switch.

It should look like this: -startupcmd=batch.

The starting of batch using -startupcmd parameter involves these four classes:

SysStartupCmdBatchRun and

In order to specify a batch group using the -startupcmd parameter use this kind of startup parameter: startupcmd=batch_invoice

The thing is, that SysStartupCmd class takes any ‘_’ sign as a separator for the startupCmd, treating batch_invoice as the command batch with invoice as the parameter. The Application class redirects control to SysStartupCmd when the -startupcmd parameter are specified. SysStartupCmd constructs a child class based on the command: SysStartupCmdBatchRun. The SysStartupCmdBatchRun class instantiates a BatchRun and calls run. Modifying infoRun as this:

void infoRun()

batchRun batchRun = new batchRun();
batchRun.parmGroupId(parm); // added;


will get your batch server up and running with a specified batch group right from the command line!

This seems to be it, but there is one more problem appears! How to make sure that this Axapta client (aka batch server) always starts when your server is started? Well, you can put it into your windows Startup menu, but then you have to make sure to login with your profile every time server starts! This is not appropriate solution for the server, so we will use standard windows services. To setup user defined windows server we will need to make some small modifications into the windows registry. Here are 6 easy steps to perform:

1. At a MS-DOS command prompt(running CMD.EXE), type the following command:

[path]\INSTSRV.EXE [My Service] [path]\SRVANY.EXE

where path is the drive and directory of the Windows NT Resource Kit (i.e., C:\RESKIT) and My Service is the name of the service you are creating. Example:

C:\Program Files\Resource Kit\Instsrv.exe Notepad C:\Program Files\Resource Kit\Srvany.exe

NOTE: To verify that the service was created correctly, check the registry to verify that the ImagePath value under

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\service name

is set to point to SRVANY.EXE. If this is not set correctly, the service will stop shortly after it starts and return an Event ID 7000 “The service name failed to start.”

NOTE: You should back up the registry before you edit it.

2. Run Registry Editor (Regedt32.exe)and locate the following subkey:


3. From the Edit menu, click Add Key. Type the following and click OK:

Key Name: Parameters
Class : [leave blank]

4. Select the Parameters key.

5. From the Edit menu, click Add Value. Type the following and click OK:

Value Name: Application
Data Type : REG_SZ
String : [path]\[application.ext]

where [path]\[application.ext] is the drive and full path to the application executable including the extension (i.e.,C:\WinNT\Notepad.exe) In our case you should type something like this:

[path to your axapta client bin]\ax32.exe startupcmd=batch_yourBatchGroup

6. Close Registry Editor.

By default, a newly created service it configured to run Automatically when the system is restarted. To change this setting to Manual, run the Services applet from Control Panel and change the Startup value to Manual. A service set to Manual can be started in one of several ways:

– From the Services applet in Control Panel

– From a MS-DOS command prompt, type the following: NET START [My Service]

– Use the Sc.exe utility from the Resource Kit. Type the following from a MS-DOS command prompt:

[path]\Sc.exe start [my service]

where [path] is the drive and directory of the Windows NT Resource Kit (i.e., C:\Reskit).

IMPORTANT: Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information on how to do this, view the “Restoring the Registry” or the “Restoring a Registry Key” online Help topics in Registry Editor.


Thanks yuriir