Step 2: Preparing the Project for Debugging

To find the workflow event that you can use in a customization project, you can 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. 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 MYOB Acumatica and install it again with the Install Debugger Tools check box selected. For details, see MYOB Acumatica Installation On-Premises: To Install the MYOB Acumatica Tools (Optional).

    Tip:
    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.
  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 SmartFix_T270 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 in your MYOB Acumatica instance, such as C:\TCourseInstances\SmartFix_T270\Bin.
    5. Click OK.
  4. 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.
  5. Add a breakpoint inside the Release method, as shown in the following screenshot.
    Figure 2. The source code of the Release action


  6. Attach the Visual Studio debugger to the w3wp.exe running process.
    Tip:
    For details about attaching to the process, see To Debug the Customization Code.
  7. Start debugging by doing the following:
    1. In MYOB Acumatica, open the Payments and Applications (AR302000) 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 do not need to customize the closing of AR invoices as well.