Back to T190: QuickStartInCustomization
Lesson 6: Debugging Customization Code
Aer you have added some code to your customization, you can debug the code, if necessary. The only way to debug customization code is to use Visual Studio. You can also debug the source code of Acumatica ERP to find out the method that you need to override to modify the business logic of Acumatica ERP. For example, you may need to customize the release process of a payment. In this lesson, you will explore the code of the payment release process through debugging.
Lesson Objectives
As you complete this lesson, you will learn how to debug the source code of Acumatica ERP.
Step 6.1: Debugging the Acumatica ERP Source Code
Acumatica ERP has open source code, which you can easily view with the Source Code browser. However, in order to find a method that you need to override, it is helpful to debug Acumatica ERP source code with breakpoints and see which breakpoint is hit in which scenario. To prepare the PhoneRepairShop_Code project for the debugging of the Acumatica ERP code, you should do the following:
- Make sure the Acumatica program database (PDB) files are located in the Bin folder of the Acumatica ERP
instance folder that you are using for this activity.
The PDB files were copied to the Files\Bin folder of the Acumatica ERP installation folder (such as
C:\Program Files\Acumatica ERP\Files\Bin) during the installation process if the Install
Debugger Tools check box was selected in the Acumatica ERP Installation wizard. When you create a new
instance or update an existing one, these PDB files are copied to the Bin folder of the instance. If you did
not select the Install Debugger Tools check box during installation, you should remove Acumatica ERP
and install it again with the Install Debugger Tools check box selected. For details, see Acumatica ERP
Installation On-Premises: To Install the Acumatica ERP Tools (Optional).
A PDB file holds debugging and project state information that is used for incremental linking of a debug configuration of your program. In general, a PDB file contains the link between compiler instructions and lines in source code. - Configure the Web.config file of the instance by doing the following:
a. In the file system, open in the text editor the Web.config file, which is located in the root folder of the
PhoneRepairShop instance.
b. In the <system.web> tag of the file, locate the
element. c. Set the debug attribute of the element to True, as shown in the following code. <system.web> <compilation debug="True" ...> d. Save your changes. - Configure the PhoneRepairShop_Code project for debugging by doing the following:
a. In Visual Studio, open the PhoneRepairShop_Code solution, which includes both the
PhoneRepairShop_Code project and the website.
b. On the main menu, select Tools > Options.
Lesson 6: Debugging Customization Code | 54
c. In the Debugging > General section, clear the Enable Just My Code check box, as shown in the following screenshot.
Figure: The cleared Enable Just My Code check box
d. In the Debugging > Symbols section, in the Symbols file (.pdb) locations list, add the path to the location of the PDB files in your Acumatica ERP instance. e. Click OK. - To view the source code of the Release action of the Payments and Applications (AR302000) form, open the PX.Objects.AR.ARPaymentEntry graph: In the website folder in the Solution Explorer, select App_Data > CodeRepository > PX.Objects > AR > ARPaymentEntry.cs, and go to the definition of the Release action—that is, the IEnumerable Release(PXAdapter adapter) method.
- Add a breakpoint inside the Release method, as shown in the following screenshot.
Figure: The source code of the Release action - Attach the Visual Studio debugger to the w3wp.exe running process.
For details about attaching to the process, see To Debug the Customization Code. - Start debugging by doing the following:
a. In Acumatica ERP, open the Payments and Applications (AR302000) form.
b. Create a payment.
c. On the form toolbar, click the Release button.
Wait until the breakpoint is hit.
Lesson 6: Debugging Customization Code | 55
d. In Visual Studio, view the debug information for the Release method. If an invoice was created for a repair work order with only non-stock items, by default, an AR invoice would be created instead of the SO invoice. There is no difference for the release of a payment for AR and SO invoices, so you do not need to customize the closing of AR invoices as well.
Related Links
- To View and Debug Acumatica ERP Source Code
Lesson Summary
In this lesson, you have learned how to debug the code of Acumatica ERP by using program database (PDB) files.