Step 2: Preparing a Project for Debugging

To find the event that you can use in the custom workflow, it is helpful to debug the MYOB Acumatica source code with breakpoints and see which breakpoint is hit in which scenario. In this step, you will prepare the PhoneRepairShop_Code for debugging in Visual Studio.

To prepare the PhoneRepairShop_Code project for the debugging of the MYOB Acumatica code, you should do the following:

  1. Make sure the MYOB program database (PDB) files are located in the Bin folder of the MYOB Acumatica instance folder that you are using for this activity (for example, in SmartFix_T270\Bin).

    The PDB files were copied to the Files\Bin folder of the MYOB Acumatica 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 MYOB Acumatica Installation wizard. With the check box selected when you create a new instance or update an existing one, the 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 MYOB Acumatica and install it again with the Install Debugger Tools check box selected. For details, see To Install the MYOB Acumatica Tools.

    Tip: A PDB file holds debugging and project state information that allows incremental linking of a debug configuration of your program. In general, a PDB file contains the link between compiler instructions and some lines in source code.
  2. Configure the Web.config file of the instance by doing the following:
    1. In the file system, open in the text editor the Web.config file, which is located in the root folder of the PhoneRepairShop instance.
    2. In the <system.web> tag of the file, locate the <compilation> element.
    3. Set the debug attribute of the element to True, as shown in the following code.
      <system.web>
       <compilation debug="True" ...>
    4. Save your changes.
  3. Configure the PhoneRepairShop_Code project for debugging by doing the following:
    1. In Visual Studio, open the PhoneRepairShop_Code solution, which includes both the PhoneRepairShop_Code project and the PhoneRepairShop website.
    2. On the main menu, select Tools > Options.
    3. In the Debugging > General section, clear the Enable Just My Code check box, as shown in the following screenshot.
      Figure 1. The cleared Enable Just My Code check box


    4. In the Debugging > Symbols section, in the Symbols file (.pdb) locations list, add the path to the location of the PDB files that you discovered in Instruction 1 of this step, such as C:\Training\SmartFix_T270\Bin.
    5. Click OK.
  4. Open the MYOB Acumatica source code files. For the SmartFix_T270 instance, all files are located in the SmartFix_T270/App_Data/CodeRepository folder.
  5. 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 Solution Explorer, select SmartFix_T270 > 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. The code should look as shown in the following screenshot.
    Figure 2. The source code of the Release action


  6. Add a breakpoint inside the Release method, as shown in the screenshot above.
  7. Attach the Visual Studio debugger to a running process.
  8. Start debugging by doing the following:
    1. In MYOB Acumatica, open the Payments and Applications form.
    2. Create a payment.
    3. On the form toolbar, click the Release button.

      Wait until the breakpoint is hit.

    4. In Visual Studio, view the debug information for the Release method.
Tip: 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 don't need to customize the closing of AR invoices as well.