Step 1: Adding a Graph Action

In this step, you will create an extension of a graph of the Invoices (SO303000) form. In the extension, you will add an action that opens a repair work order. Do the following:

  1. Learn the name of the graph where the action should be added:
    1. On the Invoices form, click Ctrl + Alt, and click the Summary area of the form.
    2. In the Element Properties dialog box, notice the name in the Business Logic box: SOInvoiceEntry.
  2. In the PhoneRepairShop_Code project, create an extension of the SOInvoiceEntry graph, as the following code shows.
    namespace PhoneRepairShop
    {
        public class SOInvoiceEntry_Extension : PXGraphExtension<SOInvoiceEntry>
        {
        }
    }
    Tip: Use Acuminator to suppress the PX1016 error in a comment. In this activity, for simplicity, the extension is always active.
  3. In the graph extension, implement the viewOrder action, as the following code shows.
            public PXAction<ARInvoice> ViewOrder;
            [PXButton, PXUIField(DisplayName = "View Repair Work Order")]
            protected virtual IEnumerable viewOrder(PXAdapter adapter)
            {
                var orderEntry = PXGraph.CreateInstance<RSSVWorkOrderEntry>();
                var order = orderEntry.WorkOrders.Search<RSSVWorkOrder.invoiceNbr>(
                    Base.Document.Current.RefNbr);
                if (order == null)
                    return adapter.Get();
    
                orderEntry.WorkOrders.Current = order;
                throw new PXRedirectRequiredException(orderEntry, true,
                    nameof(ViewOrder))
                {
                    Mode = PXBaseRedirectException.WindowMode.NewWindow
                };
            }
  4. Add the following using directives.
    using PX.Data;
    using PX.Objects.AR;
    using System.Collections;
    using PX.Objects.SO;
  5. Save your changes.