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:
- Learn the name of the graph where the action should be added:
- On the Invoices form, click Ctrl + Alt, and click the Summary area of the form.
- In the Element Properties dialog box, notice the name in the Business Logic box: SOInvoiceEntry.
- In the
PhoneRepairShop_Code
project, create an extension of theSOInvoiceEntry
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. - 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 }; }
- Add the following using
directives.
using PX.Data; using PX.Objects.AR; using System.Collections; using PX.Objects.SO;
- Save your changes.