Today I would like to discuss how to debug X++ code in a batch server. One of the common scenarios in AX development is the debugging of X++ code in the client.
For example, if you want to debug the SalesFormLetter class after posting either a Packing Slip or an Invoice, you just would go to the AOT > Classes>SalesFormLetter look for the method you want to debug and add a breakpoint. Simple!
In AX 2009, however, we have the ability to run Batch jobs directly on the server (unlike prior versions (i.e. 3.5)). The problem is that to accomplish this, we have to configure a few things.
The following are the steps to accomplish debugging X++ code in a batch server. The example is going to be using the SalesFormLetter class run method.
NOTE: Please use a Development or Test environment to try these steps.
1- Open the Client Configuration Utility and Click the Manage button. Choose Create New Configuration.
2- Give it a name. (I have chose Debug2713)
3- Set the server name, instance name and port (the default for the first instance of AX will be 2712. If you have more than one instance make sure you have the right port. In my case the AX second instance is 2713)
4- Go to the developer tab and check the both "Enable user breakpoints to debug in the business connector" and "Enable global breakpoints to debug code running in the business connector or client" check boxes.
12 - Go to AR > Common Forms and open the Sales Order Details form. Choose an Open Order and click the Post button. Choose Packing Slip (i.e.)
13 - The SalesEditForm will open. Click the Batch button and set the batch.
14- After clicking the OK button you should see the following message
If you want to check the status of your batch you can go to Basic > Inquiries >Batch Job. Your scheduled job should be in there. Wait a few minutes and the debugger should open at the breakpoint you inserted before.
NOTE: Sometimes you will have to restart the AOS service when the debugger does not open and your job has already executed. In addition, you MUST have a batch group setup.
For example, if you want to debug the SalesFormLetter class after posting either a Packing Slip or an Invoice, you just would go to the AOT > Classes>SalesFormLetter look for the method you want to debug and add a breakpoint. Simple!
In AX 2009, however, we have the ability to run Batch jobs directly on the server (unlike prior versions (i.e. 3.5)). The problem is that to accomplish this, we have to configure a few things.
The following are the steps to accomplish debugging X++ code in a batch server. The example is going to be using the SalesFormLetter class run method.
NOTE: Please use a Development or Test environment to try these steps.
1- Open the Client Configuration Utility and Click the Manage button. Choose Create New Configuration.
2- Give it a name. (I have chose Debug2713)
3- Set the server name, instance name and port (the default for the first instance of AX will be 2712. If you have more than one instance make sure you have the right port. In my case the AX second instance is 2713)
4- Go to the developer tab and check the both "Enable user breakpoints to debug in the business connector" and "Enable global breakpoints to debug code running in the business connector or client" check boxes.
5- Now open the Server Configuration File and Click the Manage button. Choose Create New Configuration. Give it a name (i.e. Debug)
6- Set the application file location and the alternate bin directory and the Application instance. In addition, check both the "Enable breakpoints to debug X++ code running on this server" and "Enable global breakpoints to debug X++ code running in batch jobs" check boxes.
7- Click the Database Connection tab and set both the server name and database name.
8- Open the AR module and go to Periodic > Clean Up > Sales update history clean up
9- Choose the Executed Clean Up option and a date and click OK.
10- Open the AOT, go to Classes and look for the SalesFormLetter class. Open the class and look for the Run method and place a breakpoint anywhere in the code.
12- Open the AX 2009 debugger
13 - The SalesEditForm will open. Click the Batch button and set the batch.
14- After clicking the OK button you should see the following message
If you want to check the status of your batch you can go to Basic > Inquiries >Batch Job. Your scheduled job should be in there. Wait a few minutes and the debugger should open at the breakpoint you inserted before.
NOTE: Sometimes you will have to restart the AOS service when the debugger does not open and your job has already executed. In addition, you MUST have a batch group setup.
No comments:
Post a Comment